

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>scitools.easyviz.vtk_ &mdash; SciTools 0.8.3 documentation</title>
    
    <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../../',
        VERSION:     '0.8.3',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="top" title="SciTools 0.8.3 documentation" href="../../../index.html" />
    <link rel="up" title="Module code" href="../../index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../../../np-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../../index.html">SciTools 0.8.3 documentation</a> &raquo;</li>
          <li><a href="../../index.html" accesskey="U">Module code</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for scitools.easyviz.vtk_</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">common</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">scitools.numpyutils</span> <span class="kn">import</span> <span class="n">ravel</span><span class="p">,</span> <span class="n">zeros</span><span class="p">,</span> <span class="n">array</span><span class="p">,</span> <span class="n">allclose</span><span class="p">,</span> <span class="n">rank</span><span class="p">,</span> \
     <span class="n">meshgrid</span><span class="p">,</span> <span class="n">newaxis</span>
<span class="kn">from</span> <span class="nn">scitools.globaldata</span> <span class="kn">import</span> <span class="n">DEBUG</span><span class="p">,</span> <span class="n">VERBOSE</span>
<span class="kn">from</span> <span class="nn">scitools.numpytools</span> <span class="kn">import</span> <span class="n">NumPy_dtype</span>
<span class="kn">from</span> <span class="nn">scitools.misc</span> <span class="kn">import</span> <span class="n">test_if_module_exists</span> 

<span class="n">test_if_module_exists</span><span class="p">(</span><span class="s">&#39;vtk&#39;</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="s">&#39;You need to install the VTK package.&#39;</span><span class="p">,</span> <span class="n">abort</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">vtk</span>
<span class="c">#import vtk.util.colors</span>
<span class="kn">import</span> <span class="nn">os</span>

<span class="kn">import</span> <span class="nn">Tkinter</span>
<span class="c"># use old behavior in Tkinter module to get around issue with Tcl</span>
<span class="c"># (more info: http://www.python.org/doc/2.3/whatsnew/node18.html)</span>
<span class="n">Tkinter</span><span class="o">.</span><span class="n">wantobjects</span> <span class="o">=</span> <span class="mi">0</span>

<span class="k">try</span><span class="p">:</span> <span class="kn">import</span> <span class="nn">vtkTkRenderWidget</span>
<span class="k">except</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">vtk.tk</span> <span class="kn">import</span> <span class="n">vtkTkRenderWidget</span>

<div class="viewcode-block" id="VtkBackend"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend">[docs]</a><span class="k">class</span> <span class="nc">VtkBackend</span><span class="p">(</span><span class="n">BaseClass</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Backend using VTK.&quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">BaseClass</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">init</span><span class="p">()</span>

<div class="viewcode-block" id="VtkBackend.init"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.init">[docs]</a>    <span class="k">def</span> <span class="nf">init</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_master</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_attrs</span><span class="p">[</span><span class="s">&#39;curfig&#39;</span><span class="p">])</span>

        <span class="c"># conversion tables for format strings</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_colors</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s">&#39;&#39;</span><span class="p">:</span>  <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="c"># No color--&gt;Blue</span>
            <span class="s">&#39;k&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="c"># Black</span>
            <span class="s">&#39;r&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="c"># Red </span>
            <span class="s">&#39;g&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="c"># Green</span>
            <span class="s">&#39;b&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="c"># Blue</span>
            <span class="s">&#39;m&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="c"># Magenta</span>
            <span class="s">&#39;c&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="c"># Cyan</span>
            <span class="s">&#39;w&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="c"># White</span>
            <span class="s">&#39;y&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="c"># Yellow</span>
            <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_arrow_types</span> <span class="o">=</span> <span class="p">{</span> <span class="c"># tuple: (type,rotation)</span>
            <span class="s">&#39;&#39;</span><span class="p">:</span>  <span class="p">(</span><span class="mi">9</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># arrow</span>
            <span class="s">&#39;.&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># no marker</span>
            <span class="s">&#39;o&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">7</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># circle</span>
            <span class="s">&#39;+&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># plus</span>
            <span class="s">&#39;x&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">45</span><span class="p">),</span> <span class="c"># x-mark</span>
            <span class="s">&#39;*&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># star --&gt; plus</span>
            <span class="s">&#39;s&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># square</span>
            <span class="s">&#39;d&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">8</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># diamond</span>
            <span class="s">&#39;v&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">180</span><span class="p">),</span><span class="c"># triangle (down) </span>
            <span class="s">&#39;^&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># triangle (up)</span>
            <span class="s">&#39;&lt;&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">90</span><span class="p">),</span> <span class="c"># triangle (left) </span>
            <span class="s">&#39;&gt;&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">270</span><span class="p">),</span><span class="c"># triangle (right)</span>
            <span class="s">&#39;p&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># pentagram --&gt; square</span>
            <span class="s">&#39;h&#39;</span><span class="p">:</span> <span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span>  <span class="c"># hexagram --&gt; square</span>
            <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_colorbar_locations</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s">&#39;North&#39;</span><span class="p">:</span> <span class="p">((</span><span class="o">.</span><span class="mi">2</span><span class="p">,</span> <span class="o">.</span><span class="mi">75</span><span class="p">),</span> <span class="p">(</span><span class="o">.</span><span class="mi">6</span><span class="p">,</span><span class="o">.</span><span class="mi">09</span><span class="p">)),</span>
            <span class="s">&#39;South&#39;</span><span class="p">:</span> <span class="p">((</span><span class="o">.</span><span class="mi">2</span><span class="p">,</span> <span class="o">.</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="o">.</span><span class="mi">6</span><span class="p">,</span> <span class="o">.</span><span class="mi">09</span><span class="p">)),</span>
            <span class="s">&#39;East&#39;</span><span class="p">:</span> <span class="p">((</span><span class="o">.</span><span class="mi">75</span><span class="p">,</span> <span class="o">.</span><span class="mi">09</span><span class="p">),</span> <span class="p">(</span><span class="o">.</span><span class="mi">1</span><span class="p">,</span> <span class="o">.</span><span class="mi">9</span><span class="p">)),</span>
            <span class="s">&#39;West&#39;</span><span class="p">:</span> <span class="p">((</span><span class="o">.</span><span class="mi">2</span><span class="p">,</span> <span class="o">.</span><span class="mi">09</span><span class="p">),</span> <span class="p">(</span><span class="o">.</span><span class="mi">1</span><span class="p">,</span> <span class="o">.</span><span class="mi">9</span><span class="p">)),</span>
            <span class="s">&#39;NorthOutside&#39;</span><span class="p">:</span> <span class="p">((</span><span class="o">.</span><span class="mi">2</span><span class="p">,</span> <span class="o">.</span><span class="mi">86</span><span class="p">),</span> <span class="p">(</span><span class="o">.</span><span class="mi">6</span><span class="p">,</span><span class="o">.</span><span class="mi">09</span><span class="p">)),</span>
            <span class="s">&#39;SouthOutside&#39;</span><span class="p">:</span> <span class="p">((</span><span class="o">.</span><span class="mi">2</span><span class="p">,</span> <span class="o">.</span><span class="mo">06</span><span class="p">),</span> <span class="p">(</span><span class="o">.</span><span class="mi">6</span><span class="p">,</span> <span class="o">.</span><span class="mi">09</span><span class="p">)),</span>
            <span class="s">&#39;EastOutside&#39;</span><span class="p">:</span> <span class="p">((</span><span class="o">.</span><span class="mi">86</span><span class="p">,</span> <span class="o">.</span><span class="mi">09</span><span class="p">),</span> <span class="p">(</span><span class="o">.</span><span class="mi">1</span><span class="p">,</span> <span class="o">.</span><span class="mi">9</span><span class="p">)),</span>
            <span class="s">&#39;WestOutside&#39;</span><span class="p">:</span> <span class="p">((</span><span class="o">.</span><span class="mo">01</span><span class="p">,</span> <span class="o">.</span><span class="mi">09</span><span class="p">),</span> <span class="p">(</span><span class="o">.</span><span class="mi">1</span><span class="p">,</span> <span class="o">.</span><span class="mi">9</span><span class="p">))</span>
            <span class="p">}</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">v</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkMesaRenderer</span><span class="p">()</span>
            <span class="n">_graphics_fact</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkGraphicsFactory</span><span class="p">()</span>
            <span class="n">_graphics_fact</span><span class="o">.</span><span class="n">SetUseMesaClasses</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
            <span class="n">_image_fact</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkImagingFactory</span><span class="p">()</span>
            <span class="n">_image_fact</span><span class="o">.</span><span class="n">SetUseMesaClasses</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
            <span class="k">del</span> <span class="n">_graphics_fact</span>
            <span class="k">del</span> <span class="n">_image_fact</span>
            <span class="k">del</span> <span class="n">v</span>
        <span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">msg</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">DEBUG</span><span class="p">:</span>
                <span class="k">print</span> <span class="s">&quot;No mesa&quot;</span><span class="p">,</span> <span class="n">msg</span>
</div>
    <span class="k">def</span> <span class="nf">_create_Tk_gui</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">fig</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gcf</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_master</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_master</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_master</span><span class="o">.</span><span class="n">withdraw</span><span class="p">()</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">_root</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Toplevel</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_master</span><span class="p">)</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s">&quot;Easyviz VTK Data Visualizer - Figure </span><span class="si">%d</span><span class="s">&quot;</span> <span class="o">%</span> \
                        <span class="bp">self</span><span class="o">.</span><span class="n">_attrs</span><span class="p">[</span><span class="s">&#39;curfig&#39;</span><span class="p">])</span>
        <span class="c"># if the window is closed, we should delete the current figure and</span>
        <span class="c"># create a new one.</span>
        <span class="k">def</span> <span class="nf">_close_fig</span><span class="p">(</span><span class="n">event</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">withdraw</span><span class="p">()</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">protocol</span><span class="p">(</span><span class="s">&quot;WM_DELETE_WINDOW&quot;</span><span class="p">,</span> <span class="n">_close_fig</span><span class="p">)</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">minsize</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="s">&quot;&lt;KeyPress-q&gt;&quot;</span><span class="p">,</span> <span class="n">_close_fig</span><span class="p">)</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">withdraw</span><span class="p">()</span>
        <span class="n">master_f</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Frame</span><span class="p">(</span><span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="p">,</span> <span class="n">relief</span><span class="o">=</span><span class="s">&#39;sunken&#39;</span><span class="p">,</span> <span class="n">bd</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
        <span class="n">master_f</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">side</span><span class="o">=</span><span class="s">&#39;top&#39;</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s">&#39;both&#39;</span><span class="p">,</span> <span class="n">expand</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
        <span class="n">renwin_frame</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Frame</span><span class="p">(</span><span class="n">master_f</span><span class="p">)</span>
        <span class="n">renwin_frame</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">side</span><span class="o">=</span><span class="s">&#39;left&#39;</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s">&#39;both&#39;</span><span class="p">,</span> <span class="n">expand</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
        <span class="n">frame</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Frame</span><span class="p">(</span><span class="n">renwin_frame</span><span class="p">)</span>
        <span class="n">frame</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">side</span><span class="o">=</span><span class="s">&#39;top&#39;</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s">&#39;both&#39;</span><span class="p">,</span> <span class="n">expand</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
        <span class="n">width</span><span class="p">,</span> <span class="n">height</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;size&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">width</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">height</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">width</span> <span class="o">=</span> <span class="mi">640</span><span class="p">;</span>  <span class="n">height</span> <span class="o">=</span> <span class="mi">480</span>
        <span class="n">tkw</span> <span class="o">=</span> <span class="n">vtkTkRenderWidget</span><span class="o">.</span><span class="n">vtkTkRenderWidget</span><span class="p">(</span><span class="n">frame</span><span class="p">,</span>
                                                  <span class="n">width</span><span class="o">=</span><span class="n">width</span><span class="p">,</span>
                                                  <span class="n">height</span><span class="o">=</span><span class="n">height</span><span class="p">)</span>
        <span class="n">tkw</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">expand</span><span class="o">=</span><span class="s">&#39;true&#39;</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s">&#39;both&#39;</span><span class="p">)</span>
        <span class="n">renwin</span> <span class="o">=</span> <span class="n">tkw</span><span class="o">.</span><span class="n">GetRenderWindow</span><span class="p">()</span>
        <span class="n">renwin</span><span class="o">.</span><span class="n">SetSize</span><span class="p">(</span><span class="n">width</span><span class="p">,</span> <span class="n">height</span><span class="p">)</span>
        <span class="c">#renwin.SetSize(width+1, height+1)</span>
        <span class="c">#renwin.SetSize(width-1, height-1)</span>
        <span class="c">#renwin.LineSmoothingOn()</span>
        <span class="c">#tkw.UpdateRenderer(0.0, 0.0)</span>
        <span class="c">#renwin.Render()</span>
        <span class="k">return</span> <span class="n">renwin</span>

    <span class="k">def</span> <span class="nf">_set_view_old</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">axis_cam</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camera&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="p">,</span> <span class="s">&#39;_vtk_camera&#39;</span><span class="p">):</span>
            <span class="c"># initialize camera:</span>
            <span class="k">pass</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c"># alter camera:</span>
            <span class="k">pass</span>
        <span class="n">camera</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkCamera</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">SetActiveCamera</span><span class="p">(</span><span class="n">camera</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camproj&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;perspective&#39;</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">ParallelProjectionOff</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">ParallelProjectionOn</span><span class="p">()</span>
        <span class="n">fp</span> <span class="o">=</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camtarget&#39;</span><span class="p">)</span>
        <span class="n">camera</span><span class="o">.</span><span class="n">SetFocalPoint</span><span class="p">(</span><span class="n">fp</span><span class="p">)</span>
        <span class="n">camera</span><span class="o">.</span><span class="n">SetViewUp</span><span class="p">(</span><span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camup&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;cammode&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;auto&#39;</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;view&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                <span class="n">camera</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">(</span><span class="n">fp</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">fp</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="n">fp</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                <span class="n">camera</span><span class="o">.</span><span class="n">Azimuth</span><span class="p">(</span><span class="o">-</span><span class="mf">37.5</span><span class="p">)</span>
                <span class="n">camera</span><span class="o">.</span><span class="n">Elevation</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">camera</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">(</span><span class="n">fp</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">fp</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">(</span><span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;campos&#39;</span><span class="p">))</span>
        <span class="c">#camera.ComputeViewPlaneNormal()</span>
        <span class="c">#camera.OrthogonalizeViewUp()</span>
        <span class="k">if</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camva&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">SetViewAngle</span><span class="p">(</span><span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camva&#39;</span><span class="p">))</span>
        <span class="n">azimuth</span> <span class="o">=</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;azimuth&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">azimuth</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;view&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                <span class="n">azimuth</span> <span class="o">+=</span> <span class="mf">37.5</span> <span class="c"># compensate for above</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">Azimuth</span><span class="p">(</span><span class="n">azimuth</span><span class="p">)</span>
        <span class="n">elevation</span> <span class="o">=</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;elevation&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">elevation</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;view&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                <span class="n">elevation</span> <span class="o">-=</span> <span class="mi">30</span> <span class="c"># compensate for above</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">Elevation</span><span class="p">(</span><span class="n">elevation</span><span class="p">)</span>
        <span class="c"># make all actors fit inside the current scene:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">ResetCamera</span><span class="p">()</span>
        <span class="n">camera</span><span class="o">.</span><span class="n">Zoom</span><span class="p">(</span><span class="n">axis_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camzoom&#39;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_camera</span> <span class="o">=</span> <span class="n">camera</span>

    <span class="k">def</span> <span class="nf">_initialize_camera</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">ax_cam</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camera&#39;</span><span class="p">)</span>
        <span class="n">camera</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkCamera</span><span class="p">()</span>
        <span class="n">fp</span> <span class="o">=</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camtarget&#39;</span><span class="p">)</span>
        <span class="n">camera</span><span class="o">.</span><span class="n">SetFocalPoint</span><span class="p">(</span><span class="n">fp</span><span class="p">)</span>
        <span class="n">camera</span><span class="o">.</span><span class="n">SetViewUp</span><span class="p">(</span><span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camup&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;cammode&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;auto&#39;</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;view&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                <span class="n">camera</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">(</span><span class="n">fp</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">fp</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="n">fp</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                <span class="n">camera</span><span class="o">.</span><span class="n">Azimuth</span><span class="p">(</span><span class="o">-</span><span class="mf">37.5</span><span class="p">)</span>
                <span class="n">camera</span><span class="o">.</span><span class="n">Elevation</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">camera</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">(</span><span class="n">fp</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">fp</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">(</span><span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;campos&#39;</span><span class="p">))</span>
        <span class="n">azimuth</span> <span class="o">=</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;azimuth&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">azimuth</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;view&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                <span class="n">azimuth</span> <span class="o">+=</span> <span class="mf">37.5</span> <span class="c"># compensate for above</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">Azimuth</span><span class="p">(</span><span class="n">azimuth</span><span class="p">)</span>
        <span class="n">elevation</span> <span class="o">=</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;elevation&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">elevation</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;view&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                <span class="n">elevation</span> <span class="o">-=</span> <span class="mi">30</span> <span class="c"># compensate for above</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">Elevation</span><span class="p">(</span><span class="n">elevation</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">camera</span>

    <span class="k">def</span> <span class="nf">_update_camera</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">ax_cam</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camera&#39;</span><span class="p">)</span>
        <span class="n">camera</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_camera</span>
        <span class="k">return</span> <span class="n">camera</span>

    <span class="k">def</span> <span class="nf">_set_view</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">ax_cam</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camera&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="p">,</span> <span class="s">&#39;_vtk_camera&#39;</span><span class="p">):</span>
            <span class="n">camera</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_initialize_camera</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c">#camera = self._update_camera()</span>
            <span class="n">camera</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_initialize_camera</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camroll&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">Roll</span><span class="p">(</span><span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camroll&#39;</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camva&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">SetViewAngle</span><span class="p">(</span><span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camva&#39;</span><span class="p">))</span>
 
        <span class="k">if</span> <span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camproj&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;perspective&#39;</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">ParallelProjectionOff</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">camera</span><span class="o">.</span><span class="n">ParallelProjectionOn</span><span class="p">()</span>
            
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">SetActiveCamera</span><span class="p">(</span><span class="n">camera</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_camera</span> <span class="o">=</span> <span class="n">camera</span>

        <span class="c"># make sure all actors are inside the current view:</span>
        <span class="n">ren</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span>
        <span class="n">ren</span><span class="o">.</span><span class="n">ResetCamera</span><span class="p">()</span>
        <span class="c">#if self._axis.getp(&#39;camera&#39;).getp(&#39;view&#39;) == 2:</span>
        <span class="c">#    ren.GetActiveCamera().Zoom(1.5)</span>
        <span class="n">camera</span><span class="o">.</span><span class="n">Zoom</span><span class="p">(</span><span class="n">ax_cam</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camzoom&#39;</span><span class="p">))</span>
       
        <span class="c"># set the camera in the vtkCubeAxesActor2D object:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetCamera</span><span class="p">(</span><span class="n">camera</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_create_labeled_axes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">ax</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="s">&#39;_vtk_axes&#39;</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkCubeAxesActor2D</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;visible&#39;</span><span class="p">):</span>
            <span class="n">tprop</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkTextProperty</span><span class="p">()</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fgcolor&#39;</span><span class="p">))</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetFontSize</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fontsize&#39;</span><span class="p">))</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetShadow</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetBold</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
            <span class="n">mode</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;mode&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">mode</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;auto&#39;</span><span class="p">,</span> <span class="s">&#39;tight&#39;</span><span class="p">]:</span>
                <span class="n">dar</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;daspect&#39;</span><span class="p">)</span>
                <span class="n">bounds</span> <span class="o">=</span> <span class="n">b</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span><span class="o">.</span><span class="n">GetBounds</span><span class="p">())</span>
                <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s">&#39;auto&#39;</span><span class="p">:</span>
                    <span class="n">incr</span> <span class="o">=</span> <span class="mf">0.1</span>
                    <span class="n">dx</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                    <span class="n">dy</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">b</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                    <span class="n">dz</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">-</span> <span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">])</span>
                    <span class="c">#b[0] -= dx*incr;  b[1] += dx*incr</span>
                    <span class="c">#b[2] -= dy*incr;  b[3] += dy*incr</span>
                    <span class="c">#b[4] -= dz*incr;  b[5] += dz*incr</span>
                <span class="n">unscaled_bounds</span> <span class="o">=</span> <span class="n">ub</span> <span class="o">=</span> <span class="n">bounds</span><span class="p">[:]</span>
                <span class="n">ub</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*=</span> <span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>  <span class="n">ub</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*=</span> <span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                <span class="n">ub</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*=</span> <span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>  <span class="n">ub</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">*=</span> <span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="n">ub</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">*=</span> <span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>  <span class="n">ub</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">*=</span> <span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
            <span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s">&#39;fill&#39;</span><span class="p">:</span>
                <span class="k">print</span> <span class="s">&quot;axis mode &#39;fill&#39; not implemented in VtkBackend&quot;</span>
            <span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s">&#39;manual&#39;</span><span class="p">:</span>
                <span class="n">bounds</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_scaled_bounds</span>
                <span class="n">unscaled_bounds</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_bounds</span>
            <span class="c">#cube_axes = vtk.vtkCubeAxesActor2D()</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetBounds</span><span class="p">(</span><span class="n">bounds</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetRanges</span><span class="p">(</span><span class="n">unscaled_bounds</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">UseRangesOn</span><span class="p">()</span>
            <span class="c">#ax._vtk_axes.SetCamera(ax._vtk_camera)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetLabelFormat</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%6.3g</span><span class="s">&quot;</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetFlyModeToOuterEdges</span><span class="p">()</span>
            <span class="c">#ax._vtk_axes.SetFontFactor(ax.getp(&#39;fontsize&#39;)/10.)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">ScalingOff</span><span class="p">()</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetAxisTitleTextProperty</span><span class="p">(</span><span class="n">tprop</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetAxisLabelTextProperty</span><span class="p">(</span><span class="n">tprop</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fgcolor&#39;</span><span class="p">))</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetCornerOffset</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetNumberOfLabels</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetXLabel</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;xlabel&#39;</span><span class="p">))</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetYLabel</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ylabel&#39;</span><span class="p">))</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">SetZLabel</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;zlabel&#39;</span><span class="p">))</span>
            <span class="k">if</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camera&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;view&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">YAxisVisibilityOff</span><span class="p">()</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="o">.</span><span class="n">YAxisVisibilityOn</span><span class="p">()</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_axes</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_box_bounds</span> <span class="o">=</span> <span class="n">bounds</span>

    <span class="k">def</span> <span class="nf">_set_box_state</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">ax</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="s">&#39;_vtk_box&#39;</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_box</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
        <span class="c"># remove old box (if present):</span>
        <span class="k">if</span> <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">GetActors</span><span class="p">()</span><span class="o">.</span><span class="n">IsItemPresent</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_box</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">RemoveActor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_box</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;box&#39;</span><span class="p">):</span>
            <span class="n">box</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkCubeSource</span><span class="p">()</span>
            <span class="c">#box.SetBounds(ax._vtk_scaled_bounds)</span>
            <span class="n">box</span><span class="o">.</span><span class="n">SetBounds</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_box_bounds</span><span class="p">)</span>
            <span class="n">box</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
            <span class="n">outline</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkOutlineFilter</span><span class="p">()</span>
            <span class="n">outline</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">box</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">outline</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_box</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_box</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fgcolor&#39;</span><span class="p">))</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_box</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_set_colormap</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">colormap</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;colormap&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">colormap</span><span class="p">,</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">):</span>
            <span class="n">colormap</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">jet</span><span class="p">()</span> <span class="c"># use default colormap</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_colormap</span> <span class="o">=</span> <span class="n">colormap</span>

    <span class="k">def</span> <span class="nf">_set_colorbar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">ax</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span>
        <span class="n">cbar</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;colorbar&#39;</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="s">&#39;_vtk_colorbar&#39;</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkScalarBarActor</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">GetActors</span><span class="p">()</span><span class="o">.</span><span class="n">IsItemPresent</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">RemoveActor2D</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">cbar</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;visible&#39;</span><span class="p">):</span>
            <span class="n">cblocation</span> <span class="o">=</span> <span class="n">cbar</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;cblocation&#39;</span><span class="p">)</span>
            <span class="n">cbloc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_colorbar_locations</span><span class="p">[</span><span class="n">cblocation</span><span class="p">]</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="o">.</span><span class="n">SetLookupTable</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colormap</span><span class="p">)</span>
            <span class="k">if</span> <span class="s">&#39;North&#39;</span> <span class="ow">in</span> <span class="n">cblocation</span> <span class="ow">or</span> <span class="s">&#39;South&#39;</span> <span class="ow">in</span> <span class="n">cblocation</span><span class="p">:</span>
                <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="o">.</span><span class="n">SetOrientationToHorizontal</span><span class="p">()</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="o">.</span><span class="n">SetOrientationToVertical</span><span class="p">()</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="o">.</span><span class="n">SetTitle</span><span class="p">(</span><span class="n">cbar</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;cbtitle&#39;</span><span class="p">))</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">(</span><span class="o">*</span><span class="n">cbloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="o">.</span><span class="n">SetPosition2</span><span class="p">(</span><span class="o">*</span><span class="n">cbloc</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
            <span class="n">tprop</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkTextProperty</span><span class="p">()</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fgcolor&#39;</span><span class="p">))</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetFontSize</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fontsize&#39;</span><span class="p">))</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">ShadowOff</span><span class="p">()</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="o">.</span><span class="n">SetTitleTextProperty</span><span class="p">(</span><span class="n">tprop</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="o">.</span><span class="n">SetLabelTextProperty</span><span class="p">(</span><span class="n">tprop</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_colorbar</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_set_shading</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">source</span><span class="p">,</span> <span class="n">actor</span><span class="p">):</span>
        <span class="n">shading</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;shading&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">shading</span> <span class="o">==</span> <span class="s">&#39;interp&#39;</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetInterpolationToGouraud</span><span class="p">()</span>
        <span class="k">elif</span> <span class="n">shading</span> <span class="o">==</span> <span class="s">&#39;flat&#39;</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetInterpolationToFlat</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span> <span class="c"># use default shading (&#39;faceted&#39;)</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetInterpolationToFlat</span><span class="p">()</span>
            <span class="n">edges</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkExtractEdges</span><span class="p">()</span>
            <span class="n">edges</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">source</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">edges</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
            <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">edges</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">ScalarVisibilityOff</span><span class="p">()</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetResolveCoincidentTopologyToPolygonOffset</span><span class="p">()</span>
            <span class="n">mesh</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
            <span class="n">mesh</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
            <span class="n">color</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linecolor&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">color</span> <span class="o">==</span> <span class="s">&#39;&#39;</span> <span class="ow">or</span> <span class="n">color</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
                <span class="n">color</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span> <span class="c"># use black as default</span>
            <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">color</span><span class="p">,</span> <span class="p">(</span><span class="nb">tuple</span><span class="p">,</span><span class="nb">list</span><span class="p">)):</span>
                <span class="k">try</span><span class="p">:</span> <span class="n">color</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_colors</span><span class="p">[</span><span class="n">color</span><span class="p">]</span>
                <span class="k">except</span><span class="p">:</span> <span class="n">color</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span> <span class="c"># use black as default</span>
            <span class="n">mesh</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="n">color</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">mesh</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_set_title</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">tprop</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkTextProperty</span><span class="p">()</span>
        <span class="n">tprop</span><span class="o">.</span><span class="n">BoldOff</span><span class="p">()</span>
        <span class="n">tprop</span><span class="o">.</span><span class="n">SetFontSize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fontsize&#39;</span><span class="p">))</span>
        <span class="n">tprop</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fgcolor&#39;</span><span class="p">))</span>
        <span class="n">tprop</span><span class="o">.</span><span class="n">SetFontFamilyToArial</span><span class="p">()</span>
        <span class="n">tprop</span><span class="o">.</span><span class="n">SetVerticalJustificationToTop</span><span class="p">()</span>
        <span class="n">tprop</span><span class="o">.</span><span class="n">SetJustificationToCentered</span><span class="p">()</span>
	<span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkTextMapper</span><span class="p">()</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fix_latex</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;title&#39;</span><span class="p">)))</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetTextProperty</span><span class="p">(</span><span class="n">tprop</span><span class="p">)</span>
	<span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor2D</span><span class="p">()</span>
        <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
        <span class="n">actor</span><span class="o">.</span><span class="n">GetPositionCoordinate</span><span class="p">()</span><span class="o">.</span><span class="n">SetCoordinateSystemToView</span><span class="p">()</span>
        <span class="n">actor</span><span class="o">.</span><span class="n">GetPositionCoordinate</span><span class="p">()</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.95</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_set_caxis</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;caxismode&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;auto&#39;</span><span class="p">:</span>
            <span class="n">caxis</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">caxis</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;caxis&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_caxis</span> <span class="o">=</span> <span class="n">caxis</span>
        
    <span class="k">def</span> <span class="nf">_data_inside_bounds</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="n">fb</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_scaled_bounds</span>
        <span class="n">bounds</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetBounds</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">fb</span><span class="p">),</span> <span class="mi">2</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">bounds</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">&lt;</span> <span class="n">fb</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">allclose</span><span class="p">(</span><span class="n">bounds</span><span class="p">[</span><span class="n">i</span><span class="p">],</span><span class="n">fb</span><span class="p">[</span><span class="n">i</span><span class="p">]):</span>
                <span class="k">return</span> <span class="bp">False</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">fb</span><span class="p">),</span> <span class="mi">2</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">bounds</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">fb</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">allclose</span><span class="p">(</span><span class="n">bounds</span><span class="p">[</span><span class="n">i</span><span class="p">],</span><span class="n">fb</span><span class="p">[</span><span class="n">i</span><span class="p">]):</span>
                <span class="k">return</span> <span class="bp">False</span>
        <span class="k">return</span> <span class="bp">True</span>

    <span class="k">def</span> <span class="nf">_cut_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">indata</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data_inside_bounds</span><span class="p">(</span><span class="n">indata</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()):</span>
            <span class="k">return</span> <span class="n">indata</span>
        <span class="n">box</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkBox</span><span class="p">()</span>
        <span class="n">box</span><span class="o">.</span><span class="n">SetBounds</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_scaled_bounds</span><span class="p">)</span>
        <span class="n">clipper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkClipPolyData</span><span class="p">()</span>
        <span class="n">clipper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">indata</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="n">clipper</span><span class="o">.</span><span class="n">SetClipFunction</span><span class="p">(</span><span class="n">box</span><span class="p">)</span>
        <span class="c">#clipper.GenerateClipScalarsOn()</span>
        <span class="c">#clipper.GenerateClippedOutputOn()</span>
        <span class="n">clipper</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span>
        <span class="n">clipper</span><span class="o">.</span><span class="n">InsideOutOn</span><span class="p">()</span>
        <span class="n">clipper</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">clipper</span>

    <span class="k">def</span> <span class="nf">_add_slices</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">,</span> <span class="n">contours</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
        <span class="n">cvector</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;cvector&#39;</span><span class="p">)</span>
        <span class="n">center</span> <span class="o">=</span> <span class="n">sgrid</span><span class="o">.</span><span class="n">GetCenter</span><span class="p">()</span>
        <span class="n">dar</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;daspect&#39;</span><span class="p">)</span>
        <span class="n">sx</span><span class="p">,</span> <span class="n">sy</span><span class="p">,</span> <span class="n">sz</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;slices&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">shape</span><span class="p">(</span><span class="n">sx</span><span class="p">))</span> <span class="o">==</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">shape</span><span class="p">(</span><span class="n">sx</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">sy</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">sz</span><span class="p">):</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">Surface</span><span class="p">(</span><span class="n">sx</span><span class="p">,</span><span class="n">sy</span><span class="p">,</span><span class="n">sz</span><span class="p">)</span>
            <span class="n">sgrid2</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_2d_structured_grid</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
            <span class="n">plane</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkStructuredGridGeometryFilter</span><span class="p">()</span>
            <span class="n">plane</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">sgrid2</span><span class="p">)</span>
            <span class="n">plane</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
            <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cut_data</span><span class="p">(</span><span class="n">plane</span><span class="p">)</span>
            <span class="n">implds</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkImplicitDataSet</span><span class="p">()</span>
            <span class="n">implds</span><span class="o">.</span><span class="n">SetDataSet</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">implds</span><span class="o">.</span><span class="n">Modified</span><span class="p">()</span>
            <span class="n">cut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkCutter</span><span class="p">()</span>
            <span class="n">cut</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">sgrid</span><span class="p">)</span>
            <span class="n">cut</span><span class="o">.</span><span class="n">SetCutFunction</span><span class="p">(</span><span class="n">implds</span><span class="p">)</span>
            <span class="n">cut</span><span class="o">.</span><span class="n">GenerateValues</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
            <span class="n">cut</span><span class="o">.</span><span class="n">GenerateCutScalarsOn</span><span class="p">()</span>
            <span class="n">cut</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
            <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">cut</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetLookupTable</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_colormap</span><span class="p">)</span>
            <span class="n">caxis</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;caxis&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="n">caxis</span><span class="p">:</span>
                <span class="n">caxis</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span><span class="o">.</span><span class="n">GetScalarRange</span><span class="p">()</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetScalarRange</span><span class="p">(</span><span class="n">caxis</span><span class="p">)</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
            <span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_shading</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_actor_properties</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">cut</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">origins</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">normals</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">sx</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">sx</span><span class="p">)</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">sy</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">sy</span><span class="p">)</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
            <span class="n">sz</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">sz</span><span class="p">)</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">sx</span><span class="p">)):</span>
                <span class="n">normals</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">origins</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">sx</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">center</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">center</span><span class="p">[</span><span class="mi">2</span><span class="p">]])</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">sy</span><span class="p">)):</span>
                <span class="n">normals</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">origins</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">center</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">sy</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">center</span><span class="p">[</span><span class="mi">2</span><span class="p">]])</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">sz</span><span class="p">)):</span>
                <span class="n">normals</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">origins</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">center</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">center</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">sz</span><span class="p">[</span><span class="n">i</span><span class="p">]])</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">normals</span><span class="p">)):</span>
                <span class="n">plane</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPlane</span><span class="p">()</span>
                <span class="n">plane</span><span class="o">.</span><span class="n">SetOrigin</span><span class="p">(</span><span class="n">origins</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="n">plane</span><span class="o">.</span><span class="n">SetNormal</span><span class="p">(</span><span class="n">normals</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="n">cut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkCutter</span><span class="p">()</span>
                <span class="n">cut</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">sgrid</span><span class="p">)</span>
                <span class="n">cut</span><span class="o">.</span><span class="n">SetCutFunction</span><span class="p">(</span><span class="n">plane</span><span class="p">)</span>
                <span class="n">cut</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
                <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cut_data</span><span class="p">(</span><span class="n">cut</span><span class="p">)</span>
                <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
                <span class="k">if</span> <span class="n">contours</span><span class="p">:</span>
                    <span class="n">iso</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkContourFilter</span><span class="p">()</span>
                    <span class="n">iso</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
                    <span class="k">if</span> <span class="n">cvector</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">cvector</span><span class="p">)):</span>
                            <span class="n">iso</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">cvector</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span><span class="o">.</span><span class="n">GetScalarRange</span><span class="p">()</span>
                        <span class="n">iso</span><span class="o">.</span><span class="n">GenerateValues</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;clevels&#39;</span><span class="p">),</span> <span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span><span class="p">)</span>
                    <span class="n">iso</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
                    <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">iso</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
                <span class="n">mapper</span><span class="o">.</span><span class="n">SetLookupTable</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_colormap</span><span class="p">)</span>
                <span class="n">caxis</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;caxis&#39;</span><span class="p">)</span>
                <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="n">caxis</span><span class="p">:</span>
                    <span class="n">caxis</span> <span class="o">=</span> <span class="n">sgrid</span><span class="o">.</span><span class="n">GetScalarRange</span><span class="p">()</span>
                <span class="n">mapper</span><span class="o">.</span><span class="n">SetScalarRange</span><span class="p">(</span><span class="n">caxis</span><span class="p">)</span>
                <span class="n">mapper</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
                <span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
                <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">contours</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_set_shading</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_set_actor_properties</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">cut</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>

    <span class="k">def</span> <span class="nf">_add_isosurface</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">):</span>
        <span class="n">iso</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkContourFilter</span><span class="p">()</span>
        <span class="n">iso</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">sgrid</span><span class="p">)</span>
        <span class="n">iso</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;isovalue&#39;</span><span class="p">))</span>
        <span class="n">iso</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cut_data</span><span class="p">(</span><span class="n">iso</span><span class="p">)</span>
        <span class="n">normals</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataNormals</span><span class="p">()</span>
        <span class="n">normals</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="n">normals</span><span class="o">.</span><span class="n">SetFeatureAngle</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
        <span class="n">normals</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">normals</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetLookupTable</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_colormap</span><span class="p">)</span>
        <span class="n">caxis</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;caxis&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="n">caxis</span><span class="p">:</span>
            <span class="n">caxis</span> <span class="o">=</span> <span class="n">sgrid</span><span class="o">.</span><span class="n">GetScalarRange</span><span class="p">()</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetScalarRange</span><span class="p">(</span><span class="n">caxis</span><span class="p">)</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
        <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_set_shading</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_set_actor_properties</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">normals</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>

    <span class="k">def</span> <span class="nf">_get_2d_structured_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">vectors</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
                                <span class="n">heights</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">bottom</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
        <span class="n">indexing</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;indexing&#39;</span><span class="p">)</span>
        <span class="n">dar</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;daspect&#39;</span><span class="p">)</span>
        <span class="n">x</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;xdata&#39;</span><span class="p">))</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">y</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ydata&#39;</span><span class="p">))</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
        <span class="n">sgrid</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkStructuredGrid</span><span class="p">()</span>
        <span class="n">sgrid</span><span class="o">.</span><span class="n">SetDimensions</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;dims&#39;</span><span class="p">))</span>
        <span class="n">no_points</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;numberofpoints&#39;</span><span class="p">)</span>
        <span class="n">points</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPoints</span><span class="p">()</span>
        <span class="n">points</span><span class="o">.</span><span class="n">SetNumberOfPoints</span><span class="p">(</span><span class="n">no_points</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">vectors</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="s">&#39;scale_vectors&#39;</span><span class="p">):</span>
                <span class="n">item</span><span class="o">.</span><span class="n">scale_vectors</span><span class="p">()</span>
            <span class="n">x</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
            <span class="n">y</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
            <span class="n">u</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;udata&#39;</span><span class="p">))</span>
            <span class="n">v</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;vdata&#39;</span><span class="p">))</span>
            <span class="n">w</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;wdata&#39;</span><span class="p">)</span>
            <span class="n">z</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;zdata&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">z</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">w</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
                <span class="n">z</span> <span class="o">=</span> <span class="n">w</span> <span class="o">=</span> <span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">(</span><span class="n">u</span><span class="p">))</span>
            <span class="n">z</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">z</span><span class="p">)</span>
            <span class="n">w</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">w</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;function&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;quiver3&#39;</span><span class="p">:</span>
                <span class="n">z</span> <span class="o">=</span> <span class="n">z</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">rank</span><span class="p">(</span><span class="n">u</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                <span class="n">nx</span><span class="p">,</span> <span class="n">ny</span> <span class="o">=</span> <span class="n">shape</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">indexing</span> <span class="o">==</span> <span class="s">&#39;ij&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">nx</span><span class="p">:</span>
                        <span class="n">x</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">x</span><span class="p">[:,</span><span class="n">newaxis</span><span class="p">]</span><span class="o">*</span><span class="n">ones</span><span class="p">((</span><span class="n">nx</span><span class="p">,</span><span class="n">ny</span><span class="p">)))</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">==</span> <span class="n">ny</span><span class="p">:</span>
                        <span class="n">y</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="n">newaxis</span><span class="p">,:]</span><span class="o">*</span><span class="n">ones</span><span class="p">((</span><span class="n">nx</span><span class="p">,</span><span class="n">ny</span><span class="p">)))</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">ny</span><span class="p">:</span>
                        <span class="n">x</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">newaxis</span><span class="p">,:]</span><span class="o">*</span><span class="n">ones</span><span class="p">((</span><span class="n">nx</span><span class="p">,</span><span class="n">ny</span><span class="p">)))</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">==</span> <span class="n">nx</span><span class="p">:</span>
                        <span class="n">y</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">y</span><span class="p">[:,</span><span class="n">newaxis</span><span class="p">]</span><span class="o">*</span><span class="n">ones</span><span class="p">((</span><span class="n">nx</span><span class="p">,</span><span class="n">ny</span><span class="p">)))</span>
            <span class="n">u</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
            <span class="n">vectors</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkFloatArray</span><span class="p">()</span>
            <span class="n">vectors</span><span class="o">.</span><span class="n">SetNumberOfTuples</span><span class="p">(</span><span class="n">no_points</span><span class="p">)</span>
            <span class="n">vectors</span><span class="o">.</span><span class="n">SetNumberOfComponents</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
            <span class="n">vectors</span><span class="o">.</span><span class="n">SetNumberOfValues</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">no_points</span><span class="p">)</span>
            <span class="k">assert</span> <span class="n">shape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">==</span><span class="n">shape</span><span class="p">(</span><span class="n">y</span><span class="p">)</span><span class="o">==</span><span class="n">shape</span><span class="p">(</span><span class="n">z</span><span class="p">)</span><span class="o">==</span><span class="n">shape</span><span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">==</span><span class="n">shape</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">==</span><span class="n">shape</span><span class="p">(</span><span class="n">w</span><span class="p">),</span>\
                   <span class="s">&quot;matrix dimensions must agree&quot;</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">no_points</span><span class="p">):</span>
                <span class="n">points</span><span class="o">.</span><span class="n">SetPoint</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="n">vectors</span><span class="o">.</span><span class="n">SetTuple3</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">u</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">w</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
            <span class="n">points</span><span class="o">.</span><span class="n">Modified</span><span class="p">()</span>
            <span class="n">sgrid</span><span class="o">.</span><span class="n">SetPoints</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
            <span class="n">sgrid</span><span class="o">.</span><span class="n">GetPointData</span><span class="p">()</span><span class="o">.</span><span class="n">SetVectors</span><span class="p">(</span><span class="n">vectors</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">values</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;zdata&#39;</span><span class="p">))</span>
            <span class="k">if</span> <span class="n">heights</span><span class="p">:</span>
                <span class="n">z</span> <span class="o">=</span> <span class="n">values</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
            <span class="k">elif</span> <span class="n">bottom</span><span class="p">:</span>
                <span class="n">z</span> <span class="o">=</span> <span class="n">zeros</span><span class="p">(</span><span class="n">values</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span> <span class="n">NumPy_dtype</span><span class="p">(</span><span class="n">values</span><span class="p">))</span> <span class="o">+</span> \
                    <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_scaled_bounds</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">z</span> <span class="o">=</span> <span class="n">zeros</span><span class="p">(</span><span class="n">values</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span> <span class="n">NumPy_dtype</span><span class="p">(</span><span class="n">values</span><span class="p">))</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">cdata</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;cdata&#39;</span><span class="p">))</span>
            <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
                <span class="k">pass</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">cdata</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">cdata</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="n">values</span><span class="o">.</span><span class="n">shape</span><span class="p">:</span>
                    <span class="n">values</span> <span class="o">=</span> <span class="n">cdata</span>
            <span class="n">scalars</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkFloatArray</span><span class="p">()</span>
            <span class="n">scalars</span><span class="o">.</span><span class="n">SetNumberOfTuples</span><span class="p">(</span><span class="n">no_points</span><span class="p">)</span>
            <span class="n">scalars</span><span class="o">.</span><span class="n">SetNumberOfComponents</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
            <span class="n">nx</span><span class="p">,</span> <span class="n">ny</span> <span class="o">=</span> <span class="n">shape</span><span class="p">(</span><span class="n">values</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">shape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">==</span> <span class="p">(</span><span class="n">nx</span><span class="p">,</span><span class="n">ny</span><span class="p">)):</span>
                <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">meshgrid</span><span class="p">(</span><span class="n">ravel</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">ravel</span><span class="p">(</span><span class="n">y</span><span class="p">),</span>
                                <span class="n">sparse</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">indexing</span><span class="o">=</span><span class="n">indexing</span><span class="p">)</span>
            <span class="k">assert</span> <span class="n">shape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">z</span><span class="p">),</span> \
                   <span class="s">&quot;array dimensions must agree&quot;</span>
            <span class="n">ind</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">ny</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nx</span><span class="p">):</span>
                    <span class="n">points</span><span class="o">.</span><span class="n">SetPoint</span><span class="p">(</span><span class="n">ind</span><span class="p">,</span> <span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">],</span> <span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">])</span>
                    <span class="n">scalars</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">ind</span><span class="p">,</span> <span class="n">values</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">])</span>
                    <span class="n">ind</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">points</span><span class="o">.</span><span class="n">Modified</span><span class="p">()</span>
            <span class="n">sgrid</span><span class="o">.</span><span class="n">SetPoints</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
            <span class="n">sgrid</span><span class="o">.</span><span class="n">GetPointData</span><span class="p">()</span><span class="o">.</span><span class="n">SetScalars</span><span class="p">(</span><span class="n">scalars</span><span class="p">)</span>

        <span class="n">sgrid</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">sgrid</span>

    <span class="k">def</span> <span class="nf">_get_3d_structured_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">vectors</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
        <span class="n">indexing</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;indexing&#39;</span><span class="p">)</span>
        <span class="n">dar</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;daspect&#39;</span><span class="p">)</span>
        <span class="n">x</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;xdata&#39;</span><span class="p">))</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">y</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ydata&#39;</span><span class="p">))</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
        <span class="n">z</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;zdata&#39;</span><span class="p">))</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
        <span class="n">sgrid</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkStructuredGrid</span><span class="p">()</span>
        <span class="n">sgrid</span><span class="o">.</span><span class="n">SetDimensions</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;dims&#39;</span><span class="p">))</span>
        <span class="n">no_points</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;numberofpoints&#39;</span><span class="p">)</span>
        <span class="n">points</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPoints</span><span class="p">()</span>
        <span class="n">points</span><span class="o">.</span><span class="n">SetNumberOfPoints</span><span class="p">(</span><span class="n">no_points</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">vectors</span><span class="p">:</span>
            <span class="n">u</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;udata&#39;</span><span class="p">))</span>
            <span class="n">v</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;vdata&#39;</span><span class="p">))</span>
            <span class="n">w</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;wdata&#39;</span><span class="p">))</span>
            <span class="n">nx</span><span class="p">,</span> <span class="n">ny</span><span class="p">,</span> <span class="n">nz</span> <span class="o">=</span> <span class="n">shape</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">shape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">z</span><span class="p">)):</span>
                <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">meshgrid</span><span class="p">(</span><span class="n">ravel</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">ravel</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="n">ravel</span><span class="p">(</span><span class="n">z</span><span class="p">),</span>
                                   <span class="n">sparse</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">indexing</span><span class="o">=</span><span class="n">indexing</span><span class="p">)</span>
            <span class="k">assert</span> <span class="n">shape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">z</span><span class="p">)</span> <span class="o">==</span> \
                   <span class="n">shape</span><span class="p">(</span><span class="n">u</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">w</span><span class="p">),</span> \
                   <span class="s">&quot;array dimensions must agree&quot;</span>
                
            <span class="n">vectors</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkFloatArray</span><span class="p">()</span>
            <span class="n">vectors</span><span class="o">.</span><span class="n">SetNumberOfTuples</span><span class="p">(</span><span class="n">no_points</span><span class="p">)</span>
            <span class="n">vectors</span><span class="o">.</span><span class="n">SetNumberOfComponents</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
            <span class="n">vectors</span><span class="o">.</span><span class="n">SetNumberOfValues</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">no_points</span><span class="p">)</span>

            <span class="n">ind</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nz</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">ny</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nx</span><span class="p">):</span>
                        <span class="n">points</span><span class="o">.</span><span class="n">SetPoint</span><span class="p">(</span><span class="n">ind</span><span class="p">,</span> <span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">],</span> <span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">])</span>
                        <span class="n">vectors</span><span class="o">.</span><span class="n">SetTuple3</span><span class="p">(</span><span class="n">ind</span><span class="p">,</span> <span class="n">u</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">],</span> <span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">],</span> <span class="n">w</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">])</span>
                        <span class="n">ind</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">points</span><span class="o">.</span><span class="n">Modified</span><span class="p">()</span>
            <span class="n">sgrid</span><span class="o">.</span><span class="n">SetPoints</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
            <span class="n">sgrid</span><span class="o">.</span><span class="n">GetPointData</span><span class="p">()</span><span class="o">.</span><span class="n">SetVectors</span><span class="p">(</span><span class="n">vectors</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">scalars</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkFloatArray</span><span class="p">()</span>
            <span class="n">scalars</span><span class="o">.</span><span class="n">SetNumberOfTuples</span><span class="p">(</span><span class="n">no_points</span><span class="p">)</span>
            <span class="n">scalars</span><span class="o">.</span><span class="n">SetNumberOfComponents</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
            
            <span class="n">v</span> <span class="o">=</span> <span class="n">asarray</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;vdata&#39;</span><span class="p">))</span>
            <span class="c"># TODO: what about pseudocolor data?</span>
            <span class="c">#cdata = ravel(item.getp(&#39;cdata&#39;))</span>
            <span class="c">#if cdata is not None:</span>
            <span class="c">#    v = cdata</span>
            <span class="n">nx</span><span class="p">,</span> <span class="n">ny</span><span class="p">,</span> <span class="n">nz</span> <span class="o">=</span> <span class="n">shape</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">shape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">z</span><span class="p">)</span> <span class="o">==</span> <span class="p">(</span><span class="n">nx</span><span class="p">,</span><span class="n">ny</span><span class="p">,</span><span class="n">nz</span><span class="p">)):</span>
                <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">meshgrid</span><span class="p">(</span><span class="n">ravel</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">ravel</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="n">ravel</span><span class="p">(</span><span class="n">z</span><span class="p">),</span>
                                   <span class="n">sparse</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">indexing</span><span class="o">=</span><span class="n">indexing</span><span class="p">)</span>
            <span class="k">assert</span> <span class="n">shape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">z</span><span class="p">)</span> <span class="o">==</span> <span class="n">shape</span><span class="p">(</span><span class="n">v</span><span class="p">),</span> \
                   <span class="s">&quot;array dimensions must agree&quot;</span>
            <span class="n">ind</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nz</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">ny</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nx</span><span class="p">):</span>
                        <span class="n">points</span><span class="o">.</span><span class="n">SetPoint</span><span class="p">(</span><span class="n">ind</span><span class="p">,</span> <span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">],</span> <span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">])</span>
                        <span class="n">scalars</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">ind</span><span class="p">,</span> <span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">])</span>
                        <span class="n">ind</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">points</span><span class="o">.</span><span class="n">Modified</span><span class="p">()</span>
            <span class="n">sgrid</span><span class="o">.</span><span class="n">SetPoints</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
            <span class="n">sgrid</span><span class="o">.</span><span class="n">GetPointData</span><span class="p">()</span><span class="o">.</span><span class="n">SetScalars</span><span class="p">(</span><span class="n">scalars</span><span class="p">)</span>
            
        <span class="n">sgrid</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">sgrid</span>

    <span class="k">def</span> <span class="nf">_add_surface</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">):</span>
        <span class="n">plane</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkStructuredGridGeometryFilter</span><span class="p">()</span>
        <span class="n">plane</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">sgrid</span><span class="p">)</span>
        <span class="n">plane</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cut_data</span><span class="p">(</span><span class="n">plane</span><span class="p">)</span>
        <span class="n">normals</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataNormals</span><span class="p">()</span>
        <span class="n">normals</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="n">normals</span><span class="o">.</span><span class="n">SetFeatureAngle</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
        <span class="n">normals</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkDataSetMapper</span><span class="p">()</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">normals</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetLookupTable</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_colormap</span><span class="p">)</span>
        <span class="n">caxis</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;caxis&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="n">caxis</span><span class="p">:</span>
            <span class="n">caxis</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span><span class="o">.</span><span class="n">GetScalarRange</span><span class="p">()</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetScalarRange</span><span class="p">(</span><span class="n">caxis</span><span class="p">)</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
        <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;wireframe&#39;</span><span class="p">):</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetRepresentationToWireframe</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_shading</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_set_actor_properties</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_add_legend</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">normals</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">normals</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        
    <span class="k">def</span> <span class="nf">_add_contours</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">):</span>
        <span class="n">plane</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkStructuredGridGeometryFilter</span><span class="p">()</span>
        <span class="n">plane</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">sgrid</span><span class="p">)</span>
        <span class="n">plane</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cut_data</span><span class="p">(</span><span class="n">plane</span><span class="p">)</span>
        <span class="n">filled</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;filled&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">filled</span><span class="p">:</span>
            <span class="n">iso</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkBandedPolyDataContourFilter</span><span class="p">()</span>
            <span class="n">iso</span><span class="o">.</span><span class="n">SetScalarModeToValue</span><span class="p">()</span>
            <span class="n">iso</span><span class="o">.</span><span class="n">GenerateContourEdgesOn</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">iso</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkContourFilter</span><span class="p">()</span>
        <span class="n">iso</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="n">clevels</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;clevels&#39;</span><span class="p">)</span>
        <span class="n">cvector</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;cvector&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">cvector</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">clevels</span><span class="p">):</span>
                <span class="n">iso</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">cvector</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span><span class="o">.</span><span class="n">GetScalarRange</span><span class="p">()</span>
            <span class="n">iso</span><span class="o">.</span><span class="n">SetNumberOfContours</span><span class="p">(</span><span class="n">clevels</span><span class="p">)</span>
            <span class="n">iso</span><span class="o">.</span><span class="n">GenerateValues</span><span class="p">(</span><span class="n">clevels</span><span class="p">,</span> <span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span><span class="p">)</span>
        <span class="n">iso</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">isoMapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
        <span class="n">isoMapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">iso</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="n">isoMapper</span><span class="o">.</span><span class="n">SetLookupTable</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_colormap</span><span class="p">)</span>
        <span class="n">caxis</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;caxis&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="n">caxis</span><span class="p">:</span>
            <span class="n">caxis</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span><span class="o">.</span><span class="n">GetScalarRange</span><span class="p">()</span>
        <span class="n">isoMapper</span><span class="o">.</span><span class="n">SetScalarRange</span><span class="p">(</span><span class="n">caxis</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linecolor&#39;</span><span class="p">):</span> <span class="c"># linecolor is defined:</span>
            <span class="n">isoMapper</span><span class="o">.</span><span class="n">ScalarVisibilityOff</span><span class="p">()</span>
        <span class="n">isoMapper</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">isoActor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
        <span class="n">isoActor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">isoMapper</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_set_actor_properties</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">isoActor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_add_legend</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">iso</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">isoActor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>

        <span class="k">if</span> <span class="n">filled</span><span class="p">:</span> <span class="c"># create contour edges:</span>
            <span class="n">edgeMapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
            <span class="n">edgeMapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">iso</span><span class="o">.</span><span class="n">GetContourEdgesOutput</span><span class="p">())</span>
            <span class="n">edgeMapper</span><span class="o">.</span><span class="n">SetResolveCoincidentTopologyToPolygonOffset</span><span class="p">()</span>
            <span class="n">edgeActor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
            <span class="n">edgeActor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">edgeMapper</span><span class="p">)</span>
            <span class="n">edgeActor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">edgeActor</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;clabels&#39;</span><span class="p">):</span>
            <span class="c"># subsample the points and label them:</span>
            <span class="n">mask</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkMaskPoints</span><span class="p">()</span>
            <span class="n">mask</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">iso</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">mask</span><span class="o">.</span><span class="n">SetOnRatio</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span><span class="o">.</span><span class="n">GetNumberOfPoints</span><span class="p">()</span><span class="o">/</span><span class="mi">50</span><span class="p">)</span>
            <span class="n">mask</span><span class="o">.</span><span class="n">SetMaximumNumberOfPoints</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
            <span class="n">mask</span><span class="o">.</span><span class="n">RandomModeOn</span><span class="p">()</span>

            <span class="c"># Create labels for points - only show visible points</span>
            <span class="n">visPts</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkSelectVisiblePoints</span><span class="p">()</span>
            <span class="n">visPts</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">mask</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">visPts</span><span class="o">.</span><span class="n">SetRenderer</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="p">)</span>
            <span class="n">ldm</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLabeledDataMapper</span><span class="p">()</span>
            <span class="n">ldm</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">mask</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">ldm</span><span class="o">.</span><span class="n">SetLabelFormat</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%.1g</span><span class="s">&quot;</span><span class="p">)</span>
            <span class="n">ldm</span><span class="o">.</span><span class="n">SetLabelModeToLabelScalars</span><span class="p">()</span>
            <span class="n">tprop</span> <span class="o">=</span> <span class="n">ldm</span><span class="o">.</span><span class="n">GetLabelTextProperty</span><span class="p">()</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetFontFamilyToArial</span><span class="p">()</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetFontSize</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">ShadowOff</span><span class="p">()</span>
            <span class="n">tprop</span><span class="o">.</span><span class="n">BoldOff</span><span class="p">()</span>
            <span class="n">contourLabels</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor2D</span><span class="p">()</span>
            <span class="n">contourLabels</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">ldm</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">contourLabels</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_add_velocity_vectors</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">):</span>
        <span class="n">marker</span><span class="p">,</span> <span class="n">rotation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_arrow_types</span><span class="p">[</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linemarker&#39;</span><span class="p">)]</span>
        <span class="n">arrow</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkGlyphSource2D</span><span class="p">()</span>
        <span class="n">arrow</span><span class="o">.</span><span class="n">SetGlyphType</span><span class="p">(</span><span class="n">marker</span><span class="p">)</span>
        <span class="n">arrow</span><span class="o">.</span><span class="n">SetFilled</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;filledarrows&#39;</span><span class="p">))</span>
        <span class="n">arrow</span><span class="o">.</span><span class="n">SetRotationAngle</span><span class="p">(</span><span class="n">rotation</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">arrow</span><span class="o">.</span><span class="n">GetGlyphType</span><span class="p">()</span> <span class="o">!=</span> <span class="mi">9</span><span class="p">:</span> <span class="c"># not an arrow</span>
            <span class="n">arrow</span><span class="o">.</span><span class="n">DashOn</span><span class="p">()</span>
            <span class="n">arrow</span><span class="o">.</span><span class="n">SetCenter</span><span class="p">(</span><span class="o">.</span><span class="mi">75</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">arrow</span><span class="o">.</span><span class="n">SetCenter</span><span class="p">(</span><span class="o">.</span><span class="mi">5</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>        
        <span class="n">arrow</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_colors</span><span class="p">[</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linecolor&#39;</span><span class="p">)])</span>

        <span class="n">plane</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkStructuredGridGeometryFilter</span><span class="p">()</span>
        <span class="n">plane</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">sgrid</span><span class="p">)</span>
        <span class="n">plane</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cut_data</span><span class="p">(</span><span class="n">plane</span><span class="p">)</span>
        <span class="n">glyph</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkGlyph3D</span><span class="p">()</span>
        <span class="n">glyph</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span> 
        <span class="n">glyph</span><span class="o">.</span><span class="n">SetSource</span><span class="p">(</span><span class="n">arrow</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="n">glyph</span><span class="o">.</span><span class="n">SetColorModeToColorByVector</span><span class="p">()</span>
        <span class="n">glyph</span><span class="o">.</span><span class="n">SetRange</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span><span class="o">.</span><span class="n">GetScalarRange</span><span class="p">())</span>
        <span class="n">glyph</span><span class="o">.</span><span class="n">ScalingOn</span><span class="p">()</span>
        <span class="n">glyph</span><span class="o">.</span><span class="n">SetScaleModeToScaleByVector</span><span class="p">()</span>
        <span class="n">glyph</span><span class="o">.</span><span class="n">OrientOn</span><span class="p">()</span>
        <span class="n">glyph</span><span class="o">.</span><span class="n">SetVectorModeToUseVector</span><span class="p">()</span>
        <span class="n">glyph</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">glyph</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="c">#vr = data.GetOutput().GetPointData().GetVectors().GetRange()</span>
        <span class="c">#mapper.SetScalarRange(vr)</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">ScalarVisibilityOff</span><span class="p">()</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
        <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_set_actor_properties</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_add_legend</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">arrow</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">glyph</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>

    <span class="k">def</span> <span class="nf">_add_streams</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">):</span>
        <span class="n">length</span> <span class="o">=</span> <span class="n">sgrid</span><span class="o">.</span><span class="n">GetLength</span><span class="p">()</span>
        <span class="n">max_velocity</span> <span class="o">=</span> <span class="n">sgrid</span><span class="o">.</span><span class="n">GetPointData</span><span class="p">()</span><span class="o">.</span><span class="n">GetVectors</span><span class="p">()</span><span class="o">.</span><span class="n">GetMaxNorm</span><span class="p">()</span>
        <span class="n">max_time</span> <span class="o">=</span> <span class="mf">35.0</span><span class="o">*</span><span class="n">length</span><span class="o">/</span><span class="n">max_velocity</span>
        
        <span class="n">n</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;numberofstreams&#39;</span><span class="p">)</span>
        <span class="n">sx</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;startx&#39;</span><span class="p">))</span>
        <span class="n">sy</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;starty&#39;</span><span class="p">))</span>
        <span class="n">sz</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;startz&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">sz</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;startz&#39;</span><span class="p">))</span>
        <span class="n">dar</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;daspect&#39;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
            <span class="n">integ</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkRungeKutta2</span><span class="p">()</span> <span class="c"># or 4?</span>
            <span class="n">stream</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkStreamLine</span><span class="p">()</span>
            <span class="n">stream</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">sgrid</span><span class="p">)</span>
            <span class="n">stream</span><span class="o">.</span><span class="n">SetStepLength</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;stepsize&#39;</span><span class="p">))</span>
            <span class="c">#stream.SetIntegrationStepLength(item.getp(&#39;stepsize&#39;))</span>
            <span class="c">#stream.SetIntegrationDirectionToIntegrateBothDirections()</span>
            <span class="n">stream</span><span class="o">.</span><span class="n">SetIntegrationDirectionToForward</span><span class="p">()</span>
            <span class="c">#stream.SetMaximumPropagationTime(max_time)</span>
            <span class="c">#stream.SetMaximumPropagationTime(200)</span>
            <span class="n">stream</span><span class="o">.</span><span class="n">SpeedScalarsOn</span><span class="p">()</span>
            <span class="c">#stream.VorticityOn()</span>
            <span class="k">if</span> <span class="n">sz</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
                <span class="n">stream</span><span class="o">.</span><span class="n">SetStartPosition</span><span class="p">(</span><span class="n">sx</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">sy</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="mi">0</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">stream</span><span class="o">.</span><span class="n">SetStartPosition</span><span class="p">(</span><span class="n">sx</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                                        <span class="n">sy</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
                                        <span class="n">sz</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
            <span class="n">stream</span><span class="o">.</span><span class="n">SetIntegrator</span><span class="p">(</span><span class="n">integ</span><span class="p">)</span>
            <span class="n">stream</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
            <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cut_data</span><span class="p">(</span><span class="n">stream</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ribbons&#39;</span><span class="p">):</span>
                <span class="n">streamribbon</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkRibbonFilter</span><span class="p">()</span>
                <span class="n">streamribbon</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
                <span class="n">streamribbon</span><span class="o">.</span><span class="n">VaryWidthOn</span><span class="p">()</span>
                <span class="n">streamribbon</span><span class="o">.</span><span class="n">SetWidthFactor</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ribbonwidth&#39;</span><span class="p">))</span>
                <span class="c">#streamribbon.SetAngle(90)</span>
                <span class="n">streamribbon</span><span class="o">.</span><span class="n">SetDefaultNormal</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">streamribbon</span><span class="o">.</span><span class="n">UseDefaultNormalOn</span><span class="p">()</span>
                <span class="n">streamribbon</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
                <span class="n">output</span> <span class="o">=</span> <span class="n">streamribbon</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span>
            <span class="k">elif</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;tubes&#39;</span><span class="p">):</span>
                <span class="n">streamtube</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkTubeFilter</span><span class="p">()</span>
                <span class="n">streamtube</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
                <span class="n">streamtube</span><span class="o">.</span><span class="n">SetRadius</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
                <span class="n">streamtube</span><span class="o">.</span><span class="n">SetNumberOfSides</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;n&#39;</span><span class="p">))</span>
                <span class="n">streamtube</span><span class="o">.</span><span class="n">SetVaryRadiusToVaryRadiusByVector</span><span class="p">()</span>
                <span class="n">streamtube</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
                <span class="n">output</span> <span class="o">=</span> <span class="n">streamtube</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">output</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">()</span>
            <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">output</span><span class="p">)</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetLookupTable</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_colormap</span><span class="p">)</span>
            <span class="n">caxis</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;caxis&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="n">caxis</span><span class="p">:</span>
                <span class="n">caxis</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">GetBounds</span><span class="p">()[</span><span class="mi">4</span><span class="p">:]</span>
                <span class="c">#caxis = sgrid.GetScalarRange()</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetScalarRange</span><span class="p">(</span><span class="n">caxis</span><span class="p">)</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
            <span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
            <span class="c">#self._set_shading(item, stream, actor)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_actor_properties</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_add_legend</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">output</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">output</span><span class="p">)</span>
            
    <span class="k">def</span> <span class="nf">_add_line</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
        <span class="n">dar</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;daspect&#39;</span><span class="p">)</span>
        <span class="n">n</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;numberofpoints&#39;</span><span class="p">)</span>
        <span class="n">polydata</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyData</span><span class="p">()</span>
        <span class="n">polydata</span><span class="o">.</span><span class="n">SetLines</span><span class="p">(</span><span class="n">vtk</span><span class="o">.</span><span class="n">vtkCellArray</span><span class="p">())</span> 
        <span class="n">points</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPoints</span><span class="p">()</span>
        <span class="c">#points.SetNumberOfPoints(n)</span>
        <span class="n">x</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;xdata&#39;</span><span class="p">))</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">y</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ydata&#39;</span><span class="p">))</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
        <span class="n">z</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;zdata&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">z</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">z</span> <span class="o">=</span> <span class="n">ravel</span><span class="p">(</span><span class="n">z</span><span class="p">)</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">z</span> <span class="o">=</span> <span class="n">zeros</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">NumPy_dtype</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
        <span class="n">ids</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkIdList</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="n">n</span><span class="p">):</span>
            <span class="n">points</span><span class="o">.</span><span class="n">InsertNextPoint</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
            <span class="n">ids</span><span class="o">.</span><span class="n">InsertNextId</span><span class="p">(</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
            <span class="n">ids</span><span class="o">.</span><span class="n">InsertNextId</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
            <span class="n">polydata</span><span class="o">.</span><span class="n">InsertNextCell</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">ids</span><span class="p">)</span>
        <span class="n">points</span><span class="o">.</span><span class="n">InsertNextPoint</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">z</span><span class="p">[</span><span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="c"># last point</span>
        <span class="n">polydata</span><span class="o">.</span><span class="n">SetPoints</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
        <span class="n">polydata</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
        <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
        <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">polydata</span><span class="p">)</span>
        <span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
        <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_set_actor_properties</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_add_legend</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">polydata</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">AddInput</span><span class="p">(</span><span class="n">polydata</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_set_actor_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">actor</span><span class="p">):</span>
        <span class="c"># set line properties:</span>
        <span class="n">color</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linecolor&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">color</span><span class="p">,</span> <span class="p">(</span><span class="nb">tuple</span><span class="p">,</span><span class="nb">list</span><span class="p">)):</span>
            <span class="k">try</span><span class="p">:</span> <span class="n">color</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_colors</span><span class="p">[</span><span class="n">color</span><span class="p">]</span>
            <span class="k">except</span><span class="p">:</span> <span class="n">color</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="c"># use blue as default</span>
        <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="n">color</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linetype&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;--&#39;</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetLineStipplePattern</span><span class="p">(</span><span class="mi">65280</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linetype&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;:&#39;</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetLineStipplePattern</span><span class="p">(</span><span class="mh">0x1111</span><span class="p">)</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetLineStippleRepeatFactor</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
        <span class="c">#actor.GetProperty().SetPointSize(item.getp(&#39;pointsize&#39;))</span>
        <span class="n">linewidth</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linewidth&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">linewidth</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetLineWidth</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">linewidth</span><span class="p">))</span>
        
        <span class="c"># set material properties:</span>
        <span class="n">ax</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span>
        <span class="n">mat</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;material&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;opacity&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetOpacity</span><span class="p">(</span><span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;opacity&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ambient&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetAmbient</span><span class="p">(</span><span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ambient&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ambientcolor&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetAmbientColor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ambientcolor&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;diffuse&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetDiffuse</span><span class="p">(</span><span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;diffuse&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;diffusecolor&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetDiffuseColor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;diffusecolor&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;specular&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetSpecular</span><span class="p">(</span><span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;specular&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;specularpower&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetSpecularPower</span><span class="p">(</span><span class="n">mat</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;specularpower&#39;</span><span class="p">))</span>

    <span class="k">def</span> <span class="nf">_set_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;visible&#39;</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;grid&#39;</span><span class="p">):</span>
            <span class="k">return</span>
        <span class="n">b</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_box_bounds</span> <span class="c">#self._axis._vtk_scaled_bounds</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;camera&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;view&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
            <span class="n">origins</span> <span class="o">=</span> <span class="p">[[</span><span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">]],</span> <span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">]],</span> <span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">]]]</span>
            <span class="n">points1</span> <span class="o">=</span> <span class="p">[[</span><span class="n">b</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">]],</span> <span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">5</span><span class="p">]],</span> <span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">5</span><span class="p">]]]</span>
            <span class="n">points2</span> <span class="o">=</span> <span class="p">[[</span><span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">]],</span> <span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">]],</span> <span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">]]]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">origins</span> <span class="o">=</span> <span class="p">[[</span><span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span><span class="mi">0</span><span class="p">]]</span>
            <span class="n">points1</span> <span class="o">=</span> <span class="p">[[</span><span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span><span class="mi">0</span><span class="p">]]</span>
            <span class="n">points2</span> <span class="o">=</span> <span class="p">[[</span><span class="n">b</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="n">b</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span><span class="mi">0</span><span class="p">]]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">origins</span><span class="p">)):</span>
            <span class="n">plane</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPlaneSource</span><span class="p">()</span>
            <span class="n">plane</span><span class="o">.</span><span class="n">SetResolution</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span>
            <span class="n">plane</span><span class="o">.</span><span class="n">SetOrigin</span><span class="p">(</span><span class="n">origins</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
            <span class="n">plane</span><span class="o">.</span><span class="n">SetPoint1</span><span class="p">(</span><span class="n">points1</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
            <span class="n">plane</span><span class="o">.</span><span class="n">SetPoint2</span><span class="p">(</span><span class="n">points2</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
            <span class="n">plane</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>
            <span class="n">mapper</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPolyDataMapper</span><span class="p">()</span>
            <span class="n">mapper</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">plane</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">actor</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkActor</span><span class="p">()</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">SetMapper</span><span class="p">(</span><span class="n">mapper</span><span class="p">)</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetRepresentationToWireframe</span><span class="p">()</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetLineStipplePattern</span><span class="p">(</span><span class="mh">0x1111</span><span class="p">)</span>
            <span class="n">actor</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetLineStippleRepeatFactor</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">actor</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_create_vtk_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;plotitems&#39;</span><span class="p">):</span>
            <span class="n">func</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;function&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">Line</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_add_line</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">Surface</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">func</span> <span class="o">==</span> <span class="s">&#39;pcolor&#39;</span><span class="p">:</span>
                    <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_2d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">heights</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_2d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_add_surface</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">)</span>
                <span class="n">citem</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;contours&#39;</span><span class="p">)</span>
                <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">citem</span><span class="p">,</span> <span class="n">Contours</span><span class="p">):</span>
                    <span class="n">csgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_2d_structured_grid</span><span class="p">(</span><span class="n">citem</span><span class="p">,</span> <span class="n">heights</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
                                                          <span class="n">bottom</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_add_contours</span><span class="p">(</span><span class="n">citem</span><span class="p">,</span> <span class="n">csgrid</span><span class="p">)</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">Contours</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;clocation&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;surface&#39;</span><span class="p">:</span>
                    <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_2d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_2d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">heights</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_add_contours</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">)</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">VelocityVectors</span><span class="p">):</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;udata&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                    <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_3d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">vectors</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_2d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">vectors</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_add_velocity_vectors</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">)</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">Streams</span><span class="p">):</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;udata&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> 
                    <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_3d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">vectors</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_2d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">vectors</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_add_streams</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">)</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">Volume</span><span class="p">):</span>
                <span class="n">sgrid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_3d_structured_grid</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
                <span class="n">contours</span> <span class="o">=</span> <span class="n">func</span> <span class="o">==</span> <span class="s">&#39;contourslice&#39;</span>
                <span class="k">if</span> <span class="n">func</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;slice_&#39;</span><span class="p">,</span> <span class="s">&#39;contourslice&#39;</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_add_slices</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">,</span> <span class="n">contours</span><span class="o">=</span><span class="n">contours</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">func</span> <span class="o">==</span> <span class="s">&#39;isosurface&#39;</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_add_isosurface</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">sgrid</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> not yet implemented&#39;</span> <span class="o">%</span> <span class="n">item</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">Update</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">_fix_latex</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">legend</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Remove latex syntax a la $, \, {, } etc.&quot;&quot;&quot;</span>
        <span class="n">legend</span> <span class="o">=</span> <span class="n">legend</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
        <span class="c"># General fix of latex syntax (more readable)</span>
        <span class="n">legend</span> <span class="o">=</span> <span class="n">legend</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">&#39;**&#39;</span><span class="p">,</span> <span class="s">&#39;^&#39;</span><span class="p">)</span>  
        <span class="c">#legend = legend.replace(&#39;*&#39;, &#39;&#39;)</span>
        <span class="n">legend</span> <span class="o">=</span> <span class="n">legend</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">&#39;$&#39;</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">)</span>
        <span class="n">legend</span> <span class="o">=</span> <span class="n">legend</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">&#39;{&#39;</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">)</span>
        <span class="n">legend</span> <span class="o">=</span> <span class="n">legend</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">&#39;}&#39;</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">)</span>
        <span class="n">legend</span> <span class="o">=</span> <span class="n">legend</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">&#39;</span><span class="se">\\</span><span class="s">&#39;</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">legend</span>

    <span class="k">def</span> <span class="nf">_add_legend</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">,</span> <span class="n">polydata</span><span class="p">):</span>
        <span class="n">legend</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fix_latex</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;legend&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">legend</span><span class="p">:</span>
            <span class="n">ax</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span>
            <span class="n">n</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_nolegends</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_nolegends</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">SetNumberOfEntries</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_nolegends</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">SetEntrySymbol</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">polydata</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">SetEntryString</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">legend</span><span class="p">)</span>
            <span class="n">color</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_colors</span><span class="p">[</span><span class="n">item</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;linecolor&#39;</span><span class="p">)]</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">SetEntryColor</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">color</span><span class="p">)</span><span class="c">#ax.getp(&#39;fgcolor&#39;))</span>

    <span class="k">def</span> <span class="nf">_set_legends</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">ax</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span>
        <span class="n">n</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_nolegends</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">SetNumberOfEntries</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
            <span class="c">#ax._vtk_legendbox.ScalarVisibilityOff()</span>
            <span class="c">#ax._vtk_legendbox.BorderOff()</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">GetPositionCoordinate</span><span class="p">()</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="mf">0.8</span><span class="p">,</span> <span class="mf">0.2</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">GetPosition2Coordinate</span><span class="p">()</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="o">.</span><span class="mi">2</span><span class="p">,</span> <span class="n">n</span><span class="o">*.</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">GetProperty</span><span class="p">()</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;fgcolor&#39;</span><span class="p">))</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddActor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_set_lights</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="p">,</span> <span class="s">&#39;_vtk_lights&#39;</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_lights</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">else</span><span class="p">:</span> <span class="c"># remove all lights (if any)</span>
            <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_lights</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">RemoveLight</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_lights</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;lights&#39;</span><span class="p">):</span>
            <span class="n">light</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLight</span><span class="p">()</span>
            <span class="n">light</span><span class="o">.</span><span class="n">SetColor</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;lightcolor&#39;</span><span class="p">))</span>
            <span class="n">light</span><span class="o">.</span><span class="n">SetFocalPoint</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;lighttarget&#39;</span><span class="p">))</span>
            <span class="n">light</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;lightpos&#39;</span><span class="p">))</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">AddLight</span><span class="p">(</span><span class="n">light</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_lights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">light</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_setup_axis</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">ax</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span>
        <span class="n">xmin</span><span class="p">,</span> <span class="n">xmax</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;xmin&#39;</span><span class="p">),</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;xmax&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="p">[</span><span class="n">xmin</span><span class="p">,</span> <span class="n">xmax</span><span class="p">]:</span>
            <span class="n">xmin</span><span class="p">,</span> <span class="n">xmax</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;xlim&#39;</span><span class="p">)</span>
        <span class="n">ymin</span><span class="p">,</span> <span class="n">ymax</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ymin&#39;</span><span class="p">),</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ymax&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="p">[</span><span class="n">ymin</span><span class="p">,</span> <span class="n">ymax</span><span class="p">]:</span>
            <span class="n">ymin</span><span class="p">,</span> <span class="n">ymax</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;ylim&#39;</span><span class="p">)</span>
        <span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;zmin&#39;</span><span class="p">),</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;zmax&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">None</span> <span class="ow">in</span> <span class="p">[</span><span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span><span class="p">]:</span>
            <span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;zlim&#39;</span><span class="p">)</span>
        <span class="n">bnds</span> <span class="o">=</span> <span class="p">[</span><span class="n">xmin</span><span class="p">,</span> <span class="n">xmax</span><span class="p">,</span> <span class="n">ymin</span><span class="p">,</span> <span class="n">ymax</span><span class="p">,</span> <span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span><span class="p">]</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_bounds</span> <span class="o">=</span> <span class="n">bnds</span><span class="p">[:]</span>
        <span class="c"># scale axis:</span>
        <span class="n">dar</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;daspect&#39;</span><span class="p">)</span>
        <span class="n">bnds</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">bnds</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>  <span class="n">bnds</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">bnds</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">bnds</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">bnds</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>  <span class="n">bnds</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">bnds</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
        <span class="n">bnds</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="n">bnds</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>  <span class="n">bnds</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="n">bnds</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span><span class="o">/</span><span class="n">dar</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_scaled_bounds</span> <span class="o">=</span> <span class="n">bnds</span><span class="p">[:]</span>

<span class="c">##         fig = self.gcf()</span>
<span class="c">##         # clean up:</span>
<span class="c">##         if hasattr(ax, &#39;_renderer&#39;):</span>
<span class="c">##             self._g.RemoveRenderer(ax._renderer)</span>
<span class="c">##             if ax._renderer in fig._renderers:</span>
<span class="c">##                 fig._renderers.remove(ax._renderer)</span>
<span class="c">##             del ax._renderer</span>
        
<span class="c">##         ax._renderer = vtk.vtkRenderer()</span>
<span class="c">##         self._g.AddRenderer(ax._renderer)</span>
<span class="c">##         # add this new renderer to the current figures list of renderers</span>
<span class="c">##         # so we can remove it later (e.g. when using clf()):</span>
<span class="c">##         fig._renderers.append(ax._renderer)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="s">&#39;_renderer&#39;</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkRenderer</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_g</span><span class="o">.</span><span class="n">AddRenderer</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="p">)</span>
            <span class="c"># add this new renderer to the current figures list of renderers</span>
            <span class="c"># so we can remove it later (e.g. when using clf()):</span>
            <span class="n">gcf</span><span class="p">()</span><span class="o">.</span><span class="n">_renderers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="p">)</span>
            
        <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="s">&#39;_vtk_legendbox&#39;</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">RemoveActor</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="p">)</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLegendBoxActor</span><span class="p">()</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_nolegends</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_legendbox</span><span class="o">.</span><span class="n">SetNumberOfEntries</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>

        <span class="c">#ax._renderer.TwoSidedLightingOff()</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">SetBackground</span><span class="p">(</span><span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;bgcolor&#39;</span><span class="p">))</span>
        <span class="n">viewport</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;viewport&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">viewport</span><span class="p">:</span>
            <span class="n">viewport</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">SetViewport</span><span class="p">(</span><span class="n">viewport</span><span class="p">)</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">RemoveAllViewProps</span><span class="p">()</span> <span class="c"># clear current scene</span>
        <span class="c">#axshape = self.gcf().getp(&#39;axshape&#39;)</span>
        <span class="c">#ax._renderer.SetPixelAspect(axshape[1], axshape[0])</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="s">&#39;_vtk_apd&#39;</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_apd</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkAppendPolyData</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">_vtk_apd</span><span class="o">.</span><span class="n">RemoveAllInputs</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">_replot</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span> <span class="o">=</span> <span class="n">gca</span><span class="p">()</span> <span class="c"># shortcut for fast access</span>
        
        <span class="n">fig</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gcf</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">fig</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;axshape&#39;</span><span class="p">)</span> <span class="o">!=</span> <span class="n">fig</span><span class="o">.</span><span class="n">_axshape</span><span class="p">:</span>
            <span class="c"># remove all current renderers:</span>
            <span class="k">for</span> <span class="n">ren</span> <span class="ow">in</span> <span class="n">fig</span><span class="o">.</span><span class="n">_renderers</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_g</span><span class="o">.</span><span class="n">RemoveRenderer</span><span class="p">(</span><span class="n">ren</span><span class="p">)</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_renderers</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_axshape</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;axshape&#39;</span><span class="p">)</span>
            
        <span class="c">#if self._master is not None:</span>
        <span class="c">#    fig._root.withdraw()</span>

        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;plotitems&#39;</span><span class="p">))</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_setup_axis</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_lights</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_colormap</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_caxis</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_create_vtk_data</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_create_labeled_axes</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_view</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_box_state</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_colorbar</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_title</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_legends</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_set_grid</span><span class="p">()</span>

            <span class="c"># render scene:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_renderer</span><span class="o">.</span><span class="n">Render</span><span class="p">()</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;show&#39;</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">fig</span><span class="p">,</span> <span class="s">&#39;_root&#39;</span><span class="p">):</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">deiconify</span><span class="p">()</span> <span class="c"># raise window</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">update</span><span class="p">()</span>
            
        <span class="c"># render complete scene:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_g</span><span class="o">.</span><span class="n">Render</span><span class="p">()</span>
            
<div class="viewcode-block" id="VtkBackend.figure"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.figure">[docs]</a>    <span class="k">def</span> <span class="nf">figure</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Extension of BaseClass.figure&quot;&quot;&quot;</span>
        <span class="n">fig</span> <span class="o">=</span> <span class="n">BaseClass</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_g</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">fig</span><span class="o">.</span><span class="n">_g</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_create_Tk_gui</span><span class="p">()</span>
            <span class="k">except</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">TclError</span><span class="p">:</span>
                <span class="c"># can&#39;t create gui; only offscreen rendering</span>
                <span class="n">fig</span><span class="o">.</span><span class="n">_g</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkRenderWindow</span><span class="p">()</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="n">width</span><span class="p">,</span> <span class="n">height</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;size&#39;</span><span class="p">)</span>
                <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
                    <span class="n">width</span><span class="p">,</span> <span class="n">height</span> <span class="o">=</span> <span class="p">(</span><span class="mi">640</span><span class="p">,</span> <span class="mi">480</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">width</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">height</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
                    <span class="n">width</span><span class="p">,</span> <span class="n">height</span> <span class="o">=</span> <span class="p">(</span><span class="mi">640</span><span class="p">,</span> <span class="mi">480</span><span class="p">)</span>
                <span class="n">fig</span><span class="o">.</span><span class="n">_g</span><span class="o">.</span><span class="n">SetSize</span><span class="p">(</span><span class="n">width</span><span class="p">,</span> <span class="n">height</span><span class="p">)</span>
                <span class="n">fig</span><span class="o">.</span><span class="n">_g</span><span class="o">.</span><span class="n">OffScreenRenderingOn</span><span class="p">()</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_renderers</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_axshape</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;axshape&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_g</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">_g</span>  <span class="c"># link for faster access</span>
        <span class="c">#self._g.SetAAFrames(5)</span>
        <span class="k">return</span> <span class="n">fig</span>
</div>
<div class="viewcode-block" id="VtkBackend.clf"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.clf">[docs]</a>    <span class="k">def</span> <span class="nf">clf</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Clear current figure.&quot;&quot;&quot;</span>
        <span class="n">fig</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gcf</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">ren</span> <span class="ow">in</span> <span class="n">fig</span><span class="o">.</span><span class="n">_renderers</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_g</span><span class="o">.</span><span class="n">RemoveRenderer</span><span class="p">(</span><span class="n">ren</span><span class="p">)</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">_renderers</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_master</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">fig</span><span class="o">.</span><span class="n">_root</span><span class="o">.</span><span class="n">withdraw</span><span class="p">()</span> <span class="c"># hide window</span>
        <span class="k">del</span> <span class="n">fig</span><span class="o">.</span><span class="n">_g</span>
        <span class="n">BaseClass</span><span class="o">.</span><span class="n">clf</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="VtkBackend.closefig"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.closefig">[docs]</a>    <span class="k">def</span> <span class="nf">closefig</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Close figure window with number &#39;num&#39;.&quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">num</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_figs</span><span class="p">:</span>
            <span class="n">curfig</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_attrs</span><span class="p">[</span><span class="s">&#39;curfig&#39;</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">num</span><span class="p">)</span> <span class="c"># set figure with &#39;num&#39; as current figure</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
            <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_figs</span><span class="p">[</span><span class="n">num</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">curfig</span><span class="p">)</span> <span class="c"># put back the current figure</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">print</span> <span class="s">&#39;no such figure with number&#39;</span><span class="p">,</span> <span class="n">num</span>
</div>
<div class="viewcode-block" id="VtkBackend.closefigs"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.closefigs">[docs]</a>    <span class="k">def</span> <span class="nf">closefigs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Close all figure windows.&quot;&quot;&quot;</span>
        <span class="n">keys</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_figs</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span>
            <span class="n">closefig</span><span class="p">(</span><span class="n">key</span><span class="p">)</span>
        <span class="n">BaseClass</span><span class="o">.</span><span class="n">closefigs</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_attrs</span><span class="p">[</span><span class="s">&#39;curfig&#39;</span><span class="p">])</span>
</div>
<div class="viewcode-block" id="VtkBackend.hardcopy"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.hardcopy">[docs]</a>    <span class="k">def</span> <span class="nf">hardcopy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s">&quot;&quot;</span><span class="p">,</span>
                 <span class="n">quality</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span>
                 <span class="n">progressive</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
                 <span class="n">vector_file</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
                 <span class="n">landscape</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
                 <span class="n">raster3d</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
                 <span class="n">compress</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
                 <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;The figure can be stored in either a vector PostScript (PS/EPS) or</span>
<span class="sd">        PDF file using GL2PS or a image file (PNG/PNM/JPEG/TIFF/BMP) using</span>
<span class="sd">        a corresponding vtkWriter instance. PostScript output can also be</span>
<span class="sd">        generated using vtkPostScriptWriter if vector_file is set to False.</span>
<span class="sd">        TeX output is also available, but only the text output will be saved</span>
<span class="sd">        to the file.</span>

<span class="sd">        If the given filename has no extension, then EPS output will be used.</span>

<span class="sd">        Keyword arguments:</span>

<span class="sd">          quality     -- Sets the quality of the resulting image. Affects only</span>
<span class="sd">                         JPEG images. Given as an integer between 0 and 100</span>
<span class="sd">                         where 100 results in the best quality (but also</span>
<span class="sd">                         the largest file). The default is quality=100.</span>

<span class="sd">          progressive -- Sets whether to use progressive JPEG generation or</span>
<span class="sd">                         not. Defaults to False.</span>

<span class="sd">          vector_file -- If True (default), the figure will be stored as a</span>
<span class="sd">                         vector file. This is only true if either PS, EPS,</span>
<span class="sd">                         or PDF are choosen as the output file format.</span>
<span class="sd">          </span>
<span class="sd">        Additional keyword arguments (only in affect if the vector_file</span>
<span class="sd">        argument is set to True and the file format is either PS, EPS or PDF):</span>

<span class="sd">          landscape -- Sets whether to use landscape or portrait orientation.</span>
<span class="sd">                       A True value result in landscape orientation. Defaults</span>
<span class="sd">                       to False.</span>
<span class="sd">          </span>
<span class="sd">          raster3d  -- If True, this will write 3D props as raster images</span>
<span class="sd">                       while 2D props are rendered using vector graphic</span>
<span class="sd">                       primitives. Defaults to False.</span>
<span class="sd">          </span>
<span class="sd">          compress  -- Compression when generating PostScript or PDF output.</span>
<span class="sd">                       The default is False (no compression).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">filename</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s">&quot;hardcopy: No filename given, cannot save figure.&quot;</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">setp</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="n">basename</span><span class="p">,</span> <span class="n">ext</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">ext</span><span class="p">:</span>  <span class="c"># no extension given, use .eps</span>
            <span class="n">ext</span> <span class="o">=</span> <span class="s">&#39;.eps&#39;</span>
            <span class="n">filename</span> <span class="o">+=</span> <span class="n">ext</span>
        
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;show&#39;</span><span class="p">):</span>  <span class="c"># don&#39;t display to screen</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_g</span><span class="o">.</span><span class="n">OffScreenRenderingOn</span><span class="p">()</span>

        <span class="n">replot</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;replot&#39;</span><span class="p">,</span> <span class="bp">True</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">replot</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_replot</span><span class="p">()</span>

        <span class="n">color</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getp</span><span class="p">(</span><span class="s">&#39;color&#39;</span><span class="p">)</span>
        
        <span class="n">vector_file_formats</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;.ps&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s">&#39;.eps&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s">&#39;.pdf&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s">&#39;.tex&#39;</span><span class="p">:</span> <span class="mi">3</span><span class="p">}</span>
        <span class="k">if</span> <span class="n">vector_file</span> <span class="ow">and</span> <span class="n">ext</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="n">vector_file_formats</span><span class="p">:</span>
            <span class="n">exp</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkGL2PSExporter</span><span class="p">()</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">SetRenderWindow</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_g</span><span class="p">)</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">SetFilePrefix</span><span class="p">(</span><span class="n">basename</span><span class="p">)</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">SetFileFormat</span><span class="p">(</span><span class="n">vector_file_formats</span><span class="p">[</span><span class="n">ext</span><span class="o">.</span><span class="n">lower</span><span class="p">()])</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">SetCompress</span><span class="p">(</span><span class="nb">bool</span><span class="p">(</span><span class="n">compress</span><span class="p">))</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">SetLandscape</span><span class="p">(</span><span class="nb">bool</span><span class="p">(</span><span class="n">landscape</span><span class="p">))</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">SetSortToBSP</span><span class="p">()</span>
            <span class="c">#exp.SetSortToSimple() # less expensive sort algorithm</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">DrawBackgroundOn</span><span class="p">()</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">SetWrite3DPropsAsRasterImage</span><span class="p">(</span><span class="nb">bool</span><span class="p">(</span><span class="n">raster3d</span><span class="p">))</span>
            <span class="n">exp</span><span class="o">.</span><span class="n">Write</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">image_writers</span> <span class="o">=</span> <span class="p">{</span>
                <span class="s">&#39;.tif&#39;</span><span class="p">:</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkTIFFWriter</span><span class="p">(),</span>
                <span class="s">&#39;.bmp&#39;</span><span class="p">:</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkBMPWriter</span><span class="p">(),</span>
                <span class="s">&#39;.pnm&#39;</span><span class="p">:</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPNMWriter</span><span class="p">(),</span>
                <span class="s">&#39;.png&#39;</span><span class="p">:</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPNGWriter</span><span class="p">(),</span>
                <span class="s">&#39;.jpg&#39;</span><span class="p">:</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkJPEGWriter</span><span class="p">(),</span>
                <span class="s">&#39;.ps&#39;</span><span class="p">:</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPostScriptWriter</span><span class="p">(),</span>
                <span class="s">&#39;.eps&#39;</span><span class="p">:</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkPostScriptWriter</span><span class="p">(),</span> <span class="c"># no EPS file</span>
                <span class="p">}</span>
            <span class="n">w2if</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkWindowToImageFilter</span><span class="p">()</span>
            <span class="n">w2if</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_g</span><span class="p">)</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">writer</span> <span class="o">=</span> <span class="n">image_writers</span><span class="p">[</span><span class="n">ext</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span>
            <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                    <span class="s">&quot;hardcopy: File format &#39;</span><span class="si">%s</span><span class="s">&#39; is currently not supported.&quot;</span>\
                    <span class="o">%</span> <span class="n">ext</span><span class="p">)</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">writer</span><span class="o">.</span><span class="n">SetQuality</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">quality</span><span class="p">))</span>
                <span class="n">writer</span><span class="o">.</span><span class="n">SetProgressive</span><span class="p">(</span><span class="nb">bool</span><span class="p">(</span><span class="n">progressive</span><span class="p">))</span>
            <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>\
                      <span class="s">&quot;hardcopy: Integer required for the &#39;quality&#39; argument.&quot;</span><span class="p">)</span>
            <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
                <span class="k">pass</span> <span class="c"># only vtkJPEGWriter has quality and progressive attrs.</span>
            <span class="n">writer</span><span class="o">.</span><span class="n">SetFileName</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
            <span class="n">writer</span><span class="o">.</span><span class="n">SetInput</span><span class="p">(</span><span class="n">w2if</span><span class="o">.</span><span class="n">GetOutput</span><span class="p">())</span>
            <span class="n">writer</span><span class="o">.</span><span class="n">Write</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_g</span><span class="o">.</span><span class="n">OffScreenRenderingOff</span><span class="p">()</span>
</div>
    <span class="n">hardcopy</span><span class="o">.</span><span class="n">__doc__</span> <span class="o">=</span> <span class="n">BaseClass</span><span class="o">.</span><span class="n">hardcopy</span><span class="o">.</span><span class="n">__doc__</span> <span class="o">+</span> <span class="n">hardcopy</span><span class="o">.</span><span class="n">__doc__</span>

<div class="viewcode-block" id="VtkBackend.brighten"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.brighten">[docs]</a>    <span class="k">def</span> <span class="nf">brighten</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Brighten or darken color map.&quot;&quot;&quot;</span>
        <span class="n">nargs</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">nargs</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> <span class="c"># brighten(map,beta)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">):</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">&quot;brighten: map must be </span><span class="si">%s</span><span class="s">, not </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> \
                                 <span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">),</span> <span class="nb">type</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])))</span>
            <span class="n">lut</span><span class="p">,</span> <span class="n">beta</span> <span class="o">=</span> <span class="n">args</span>
        <span class="k">elif</span> <span class="n">nargs</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="c"># brighten(beta)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="p">,</span> <span class="s">&#39;_vtk_colormap&#39;</span><span class="p">):</span>
                <span class="k">print</span> <span class="s">&quot;brighten: no colormap set.&quot;</span>
                <span class="k">return</span>
            <span class="n">lut</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_axis</span><span class="o">.</span><span class="n">_vtk_colormap</span>
            <span class="n">beta</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">beta</span><span class="p">,</span> <span class="p">(</span><span class="nb">float</span><span class="p">,</span><span class="nb">int</span><span class="p">))</span> <span class="ow">or</span> <span class="p">(</span><span class="n">beta</span> <span class="o">&lt;=</span> <span class="o">-</span><span class="mi">1</span> <span class="ow">or</span> <span class="n">beta</span> <span class="o">&gt;=</span> <span class="mi">1</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">&quot;brighten: beta must be between -1 and 1&quot;</span><span class="p">)</span>
        <span class="c"># all is OK, change colormap:</span>
        <span class="n">hue</span> <span class="o">=</span> <span class="n">lut</span><span class="o">.</span><span class="n">GetHueRange</span><span class="p">()</span>
        <span class="n">val</span> <span class="o">=</span> <span class="n">lut</span><span class="o">.</span><span class="n">GetValueRange</span><span class="p">()</span>
 
    <span class="c"># colormaps</span></div>
<div class="viewcode-block" id="VtkBackend.hsv"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.hsv">[docs]</a>    <span class="k">def</span> <span class="nf">hsv</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">256</span><span class="p">):</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetHueRange</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetSaturationRange</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetValueRange</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
</div>
<div class="viewcode-block" id="VtkBackend.gray"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.gray">[docs]</a>    <span class="k">def</span> <span class="nf">gray</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">256</span><span class="p">):</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetHueRange</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetSaturationRange</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetValueRange</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
</div>
<div class="viewcode-block" id="VtkBackend.hot"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.hot">[docs]</a>    <span class="k">def</span> <span class="nf">hot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">256</span><span class="p">):</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">inc</span> <span class="o">=</span> <span class="mf">0.01175</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="mi">256</span><span class="p">)</span>
        <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">r</span> <span class="o">=</span> <span class="mf">0.0</span><span class="p">;</span> <span class="n">g</span> <span class="o">=</span> <span class="mf">0.0</span><span class="p">;</span> <span class="n">b</span> <span class="o">=</span> <span class="mf">0.0</span>
        <span class="k">while</span> <span class="n">r</span> <span class="o">&lt;=</span> <span class="mf">1.</span><span class="p">:</span>
            <span class="n">lut</span><span class="o">.</span><span class="n">SetTableValue</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">r</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
            <span class="n">r</span> <span class="o">+=</span> <span class="n">inc</span><span class="p">;</span>  <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="n">r</span> <span class="o">=</span> <span class="mf">1.</span>
        <span class="k">while</span> <span class="n">g</span> <span class="o">&lt;=</span> <span class="mf">1.</span><span class="p">:</span>
            <span class="n">lut</span><span class="o">.</span><span class="n">SetTableValue</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">r</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
            <span class="n">g</span> <span class="o">+=</span> <span class="n">inc</span><span class="p">;</span>  <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="n">g</span> <span class="o">=</span> <span class="mf">1.</span>
        <span class="k">while</span> <span class="n">b</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">256</span><span class="p">:</span> <span class="k">break</span>
            <span class="n">lut</span><span class="o">.</span><span class="n">SetTableValue</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">r</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
            <span class="n">b</span> <span class="o">+=</span> <span class="n">inc</span><span class="p">;</span>  <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
</div>
<div class="viewcode-block" id="VtkBackend.flag"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.flag">[docs]</a>    <span class="k">def</span> <span class="nf">flag</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">64</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Alternating red, white, blue, and black color map.</span>

<span class="sd">        - flag(m)</span>
<span class="sd">          &#39;m&#39; must be a multiple of 4</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="c"># the last parameter alpha is set to 1 by default</span>
        <span class="c"># in method declaration</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">m</span><span class="p">,</span><span class="mi">4</span><span class="p">):</span>
            <span class="n">lut</span><span class="o">.</span><span class="n">SetTableValue</span><span class="p">(</span><span class="n">i</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>   <span class="c"># red</span>
            <span class="n">lut</span><span class="o">.</span><span class="n">SetTableValue</span><span class="p">(</span><span class="mi">1</span><span class="o">+</span><span class="n">i</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="c"># white</span>
            <span class="n">lut</span><span class="o">.</span><span class="n">SetTableValue</span><span class="p">(</span><span class="mi">2</span><span class="o">+</span><span class="n">i</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="c"># blue</span>
            <span class="n">lut</span><span class="o">.</span><span class="n">SetTableValue</span><span class="p">(</span><span class="mi">3</span><span class="o">+</span><span class="n">i</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="c"># black</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
</div>
<div class="viewcode-block" id="VtkBackend.jet"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.jet">[docs]</a>    <span class="k">def</span> <span class="nf">jet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">256</span><span class="p">):</span>
        <span class="c"># blue, cyan, green, yellow, red, black</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetHueRange</span><span class="p">(</span><span class="mf">0.667</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
</div>
<div class="viewcode-block" id="VtkBackend.blue_to_yellow"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.blue_to_yellow">[docs]</a>    <span class="k">def</span> <span class="nf">blue_to_yellow</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">200</span><span class="p">):</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">m</span><span class="p">):</span>
            <span class="n">frac</span> <span class="o">=</span> <span class="n">i</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span> <span class="o">/</span> <span class="mf">2.0</span> <span class="o">-</span> <span class="mf">1.0</span><span class="p">)</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">frac</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">):</span>
                <span class="n">r</span> <span class="o">=</span> <span class="n">frac</span>
                <span class="n">g</span> <span class="o">=</span> <span class="n">r</span>
                <span class="n">b</span> <span class="o">=</span> <span class="mi">1</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">r</span> <span class="o">=</span> <span class="mi">1</span>
                <span class="n">g</span> <span class="o">=</span> <span class="n">r</span>
                <span class="n">b</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">-</span> <span class="n">frac</span>
            <span class="c"># SetTableValue(indx, red, green, blue, alpha)</span>
            <span class="n">lut</span><span class="o">.</span><span class="n">SetTableValue</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">r</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
</div>
<div class="viewcode-block" id="VtkBackend.spring"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.spring">[docs]</a>    <span class="k">def</span> <span class="nf">spring</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">256</span><span class="p">):</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetHueRange</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.17</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetSaturationRange</span><span class="p">(</span><span class="mf">0.5</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> 
        <span class="n">lut</span><span class="o">.</span><span class="n">SetValueRange</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
</div>
<div class="viewcode-block" id="VtkBackend.summer"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.summer">[docs]</a>    <span class="k">def</span> <span class="nf">summer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">256</span><span class="p">):</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetHueRange</span><span class="p">(</span><span class="mf">0.47</span><span class="p">,</span> <span class="mf">0.17</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetSaturationRange</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">)</span> 
        <span class="n">lut</span><span class="o">.</span><span class="n">SetValueRange</span><span class="p">(</span><span class="mf">0.5</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
</div>
<div class="viewcode-block" id="VtkBackend.winter"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.winter">[docs]</a>    <span class="k">def</span> <span class="nf">winter</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">256</span><span class="p">):</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetHueRange</span><span class="p">(</span><span class="mf">0.8</span><span class="p">,</span> <span class="mf">0.42</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetSaturationRange</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> 
        <span class="n">lut</span><span class="o">.</span><span class="n">SetValueRange</span><span class="p">(</span><span class="mf">0.6</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
        </div>
<div class="viewcode-block" id="VtkBackend.autumn"><a class="viewcode-back" href="../../../vtk_.html#scitools.easyviz.vtk_.VtkBackend.autumn">[docs]</a>    <span class="k">def</span> <span class="nf">autumn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="mi">256</span><span class="p">):</span>
        <span class="n">lut</span> <span class="o">=</span> <span class="n">vtk</span><span class="o">.</span><span class="n">vtkLookupTable</span><span class="p">()</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetNumberOfColors</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetHueRange</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.15</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">SetSaturationRange</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> 
        <span class="n">lut</span><span class="o">.</span><span class="n">SetValueRange</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lut</span><span class="o">.</span><span class="n">Build</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">lut</span>
    </div></div>
<span class="n">plt</span> <span class="o">=</span> <span class="n">VtkBackend</span><span class="p">()</span> <span class="c"># Create backend instance</span>
<span class="n">use</span><span class="p">(</span><span class="n">plt</span><span class="p">,</span> <span class="nb">globals</span><span class="p">())</span> <span class="c"># Export public namespace of plt to globals()</span>
<span class="n">backend</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">__file__</span><span class="p">))[</span><span class="mi">0</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../../index.html">
              <img class="logo" src="../../../_static/scitools_logo.jpg" alt="Logo"/>
            </a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../../../np-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../../index.html">SciTools 0.8.3 documentation</a> &raquo;</li>
          <li><a href="../../index.html" >Module code</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, H. P. Langtangen, J. Ring, ++.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
  </body>
</html>